如何在bash脚本中使用for循环复制和重命名文件?

use*_*583 2 linux bash shell loops

如何使用For循环将所有文件*.html复制到*.php?

帮我...

我的脚本:

#!/bin/bash
list="$(ls *.html)"
for i in "$list"
do
  newname=$(ls "$i" | sed -e 's/html/php/')
  cat beginfile > "$newname"
  cat "$i" | sed -e '1,26d' | tac | sed -e '1,21d' | tac >> "$newname"
  cat endfiel >> "$newname"
done
Run Code Online (Sandbox Code Playgroud)

或者你有另一个想法?

Chr*_*odd 5

for f in *.html; do cp $f ${f%.html}.php; done
Run Code Online (Sandbox Code Playgroud)