Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to copy and rename file with for loop in bash script?

How I can copy all file *.html to *.php with For loop?

help me...

this my script :

#!/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

or you have another ide ?

like image 654
user2467583 Avatar asked Sep 05 '25 16:09

user2467583


1 Answers

for f in *.html; do cp $f ${f%.html}.php; done
like image 121
Chris Dodd Avatar answered Sep 07 '25 13:09

Chris Dodd