How to find all the php files under current directory and add a line
How do you do that in terminal or anywhere else?
echo "//test comment" > find . -type f -name "*.js"
doesn't wor开发者_如何学Gok. I just want to add a line on top of each .js files. Thanks.
#!/bin/bash
echo "//test comment" > myline
for file in *.js; do
cp myline dummy
cat $file >> dummy
cp dummy $file
done
or:
#!/bin/bash
for file in *.js; do
sed -i '1i //test comment' $file
done
Try something like this:
find . -type f -name "*.js" -exec echo >> {} \;
精彩评论