I'm on opensus 11.3 and I am looking for a bash script to do the following:
Create directories and rename them from a
.txt
list, each new name is a new line 开发者_运维技巧on that .txtCopy
file.php
from to each new directory, and rename allfile.php
files in those directories to a specific name.Print a
"/< php ? >/"
string into the first line in each of those files.
I assume the best and fastest to accomplish this will be in bash, if you have another idea I will be happy to listen.
Edit:: This is the version modified according to OP's last comment:
#/bin/bash
while read name; do
# prepare file to copy into new dirs
echo "\<php \$city= \"$name\" ?\>" > tempfile
cat file.php >> tempfile
# create dir & copy modified file.php into it
mkdir -p "$name"
cp tempfile "$name"/filename.php
done < names.txt
精彩评论