My hosting company requires me to put #!/usr/local/bin/ruby
at the top of every RB file. Is there an easy way to use sed recursively or something that can go through and append this to the top of every rb file?
views:
34answers:
1
+2
A:
awk
$ awk 'NR==1{$0="#!/usr/local/bin/ruby\n"$0 }1' file > temp; mv temp file;
sed
sed -i.bak '1 i #!/usr/local/bin/ruby' file
to do it recursively, you can use find
find /path -type f -iname "*.rb" | while read -r FILE
do
sed -i.bak '1 i #!/usr/local/bin/ruby' $FILE
# awk 'NR==1{$0="#!/usr/local/bin/ruby\n"$0 }1' >temp ; mv temp $FILe
done
ghostdog74
2010-02-23 05:02:00