Just as a possible starting point...

On Fri, 06 Feb 2009 22:50:38 +0000, Adam Vande More <amvandem...@gmail.com> 
wrote:
> 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).





-- 
Polytropon
>From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to