Re: insert new line in files

2009-02-07 Thread Wojciech Puchar
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

Re: insert new line in files

2009-02-07 Thread Mike Clarke
On Friday 06 February 2009, Adam Vande More wrote: Progress is being made as it works in the test now with the \\ however I'm running into more things I don't understand in regards to what I need to escape in my input string. Whether to use \ or \\ will depend on your shell. You can avoid

Re: insert new line in files

2009-02-07 Thread William Gordon Rutherdale
Wojciech Puchar 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'); write a script: #!/usr/local/bin/bash (a=0 while [ $a -lt 36

insert new line in files

2009-02-06 Thread Adam Vande More
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.

Re: insert new line in files

2009-02-06 Thread Dan Nelson
In the last episode (Feb 06), Adam Vande More said: 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

Re: insert new line in files

2009-02-06 Thread Adam Vande More
Dan Nelson wrote: In the last episode (Feb 06), Adam Vande More said: 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

Re: insert new line in files

2009-02-06 Thread Steve Bertrand
Adam Vande More wrote: Dan Nelson wrote: You want: sed -e '5i\ test' test.txt i.e. a linebreak after the backslash. I had actually tried that too: sed -e '5i\ ? test' text.txt sed: 1: 5i test : command i expects \ followed by text Try: # sed -e 5i\\ ? test text.txt Note the

Re: insert new line in files

2009-02-06 Thread Dan Nelson
In the last episode (Feb 06), Adam Vande More said: Dan Nelson wrote: In the last episode (Feb 06), Adam Vande More said: 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:

Re: insert new line in files

2009-02-06 Thread Adam Vande More
Dan Nelson wrote: I had actually tried that too: sed -e '5i\ ? test' text.txt sed: 1: 5i test : command i expects \ followed by text I don't see a backslash in the error message, which means something ate it. Are you running this command from something other than the commandline or a

Re: insert new line in files

2009-02-06 Thread Adam Vande More
Adam Vande More wrote: Dan Nelson wrote: I had actually tried that too: sed -e '5i\ ? test' text.txt sed: 1: 5i test : command i expects \ followed by text I don't see a backslash in the error message, which means something ate it. Are you running this command from something other

Re: insert new line in files

2009-02-06 Thread Steve Bertrand
Adam Vande More wrote: Dan Nelson wrote: I had actually tried that too: sed -e '5i\ ? test' text.txt sed: 1: 5i test : command i expects \ followed by text I don't see a backslash in the error message, which means something ate it. Are you running this command from something

Re: insert new line in files

2009-02-06 Thread Steve Bertrand
Adam Vande More wrote: I also tried escaping ( ) . / to no avail. nevermind I see I have to \\ that as well. Okay now I'm going to try to find a way to do this with find and xargs IMHO, this has become a job for Perl :) Steve ___

Re: insert new line in files

2009-02-06 Thread Polytropon
Just as a possible starting point... On Fri, 06 Feb 2009 22:50:38 +, 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:

Re: insert new line in files

2009-02-06 Thread Adam Vande More
Steve Bertrand wrote: Adam Vande More wrote: I also tried escaping ( ) . / to no avail. nevermind I see I have to \\ that as well. Okay now I'm going to try to find a way to do this with find and xargs IMHO, this has become a job for Perl :) Steve Thanks for help