Just as a possible starting point...

On Fri, 06 Feb 2009 22:50:38 +0000, Adam Vande More <amvandem...@gmail.com> 
> 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');
> to be put into file X at line 37 where file X appears in ./subdir1, 
> .subdir2 etc. There are many subdirs or I'd just do it by hand.
> [...]
> Is sed the right tool for this?  If so, any good primers for BSD sed?

I'd suggest awk. If you have already a mechanism to "handle" each of the
files that need alteration, an awk command could be this:

awk '{ print $0; if(NR == 37) 
printf("include('/usr/home/www/imp-sites/default_inventory.php');\n"); }' <file>

It may be neccessary to have a look at the multiple ' (awk skript enclosure,
include() parameter enclusure).

>From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to