insert new line in files

Wojciech Puchar wojtek at wojtek.tensor.gdynia.pl
Sat Feb 7 01:09:14 PST 2009


> I want to insert a new line of text at a certain position in certain files 
> recursively under a directory.  More specifically, I want text like this:
>
> include('/usr/home/www/imp-sites/default_inventory.php');

write a script:

#!/usr/local/bin/bash
(a=0
while [ $a -lt 36 ];do
  read line
  echo "$line"
  a=$[a+1]
done
echo "include('/usr/home/www/imp-sites/default_inventory.php');"
while read line;do
  echo "$line"
done) <$1 >/tmp/$$
mv -f /tmp/$$ $1


run it over each file



More information about the freebsd-questions mailing list