Re: automated editing of text files

2011-09-18 Thread Ivan Shmakov
> Aéris writes: > Le 17/09/2011 00:40, Bob Proulx a écrit : […] >> * Secondly if the add-pre-nl.sh script handle multiple file >> arguments then instead of \; use + so that it calls it fewer times >> with as many file arguments as possible. It will be more efficient >> that way.

Re: sed usage (was: automated editing of text files)

2011-09-17 Thread Bob Proulx
Tom Furie wrote: > Bob Proulx wrote: > > Using sed is a good tool for this but if you want to append then you > > should use the 'a' command. > > > > $ printf "one\ntwo\nthree\nfour\n" | sed '/two/a\ > > -> foo' > > one > > two > > -> foo > > three > > four > > This doesn't quite wo

sed usage (was: automated editing of text files)

2011-09-17 Thread Tom Furie
On Fri, Sep 16, 2011 at 12:58:08PM -0600, Bob Proulx wrote: > Using sed is a good tool for this but if you want to append then you > should use the 'a' command. > > $ printf "one\ntwo\nthree\nfour\n" | sed '/two/a\ > -> foo' > one > two > -> foo > three > four This doesn't quite wor

RE: automated editing of text files

2011-09-17 Thread Bonno Bloksma
Hi Tom (and others) >> Ok, I've got most of it. The last part is more of a bash problem I think as >> most of the files have spaces in them. Not my idea, it's how the files were >> delivered to me. :-( >> >> So the command line: >>  for i in `ls *.txt` ; do ./add-pre-nl.sh $i; done >> does not cut

Re: automated editing of text files

2011-09-16 Thread Bob Proulx
Aéris wrote: > Le 17/09/2011 00:40, Bob Proulx a écrit : > > Ah... Very good! An excellent suggestion! 'find' rocks! I will > > note three things here however. > > > > * One is that the find will recurse down through a possibly deep > > hierarchy of directories. It isn't an identical alternat

Re: automated editing of text files

2011-09-16 Thread Aéris
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Le 17/09/2011 00:40, Bob Proulx a écrit : > Ah... Very good! An excellent suggestion! 'find' rocks! I will > note three things here however. > > * One is that the find will recurse down through a possibly deep > hierarchy of directories. It isn't

Re: automated editing of text files

2011-09-16 Thread Bob Proulx
Aéris wrote: > Le 16/09/2011 23:40, Bob Proulx a écrit : > > If there are no *.txt files then the file glob won't be expanded, > > nothing to expand it to, and then your shell script will get a literal > > "*.txt" as an argument. If that minor point is important to you then > > check that the file

Re: automated editing of text files

2011-09-16 Thread Aéris
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Le 16/09/2011 23:40, Bob Proulx a écrit : > If there are no *.txt files then the file glob won't be expanded, > nothing to expand it to, and then your shell script will get a literal > "*.txt" as an argument. If that minor point is important to you th

Re: automated editing of text files

2011-09-16 Thread Bob Proulx
Bonno Bloksma wrote: > The last part is more of a bash problem I think as most of the files > have spaces in them. Not my idea, it's how the files were delivered > to me. :-( > > So the command line: > for i in `ls *.txt` ; do ./add-pre-nl.sh $i; done Eww.. Don't say `ls *.txt` there but just

Re: automated editing of text files

2011-09-16 Thread Tom H
On Fri, Sep 16, 2011 at 5:14 PM, Bonno Bloksma wrote: > >>> linbobo:~/sedtest# sed 's_\n\n_\n\n\n_' >> >new.txt linbobo:~/sedtest# less new.txt > >> You want to change the regexp here. In regular expressions '^' matches > start of line and '$' matches end of line. >> Your sed instruction above sho

RE: automated editing of text files

2011-09-16 Thread Bonno Bloksma
Hi Tom (and others) >> linbobo:~/sedtest# sed 's_\n\n_\n\n\n_' > >new.txt linbobo:~/sedtest# less new.txt > You want to change the regexp here. In regular expressions '^' matches start of line and '$' matches end of line. > Your sed instruction above should be something like 's/^$/\n/', or more g

Re: automated editing of text files

2011-09-16 Thread Bob Proulx
Bonno Bloksma wrote: > Have been experimenting some with it but... > > linbobo:~/sedtest# sed 's___' new.txt > linbobo:~/sedtest# less new.txt > > And indeed I will see on that line instead of but... > > linbobo:~/sedtest# sed 's_\n\n_\n\n\n_' new.txt > linbobo:~/sedtest# less new.txt > > Wil

Re: automated editing of text files

2011-09-16 Thread rlharris
> I have a bunch of files where I need an extra line after a code. So > I need to change CRLF (or LF) to CRLFCRLF. > > Which toool can I use for that, I can't remember which tool is a good one > for this and google is no help. > I am not fluent in any of the programming languages but I do write b

Re: automated editing of text files

2011-09-16 Thread Camaleón
On Fri, 16 Sep 2011 17:24:52 +0200, Bonno Bloksma wrote: > Hi Camaleón, > >>> I have a bunch of files where I need an extra line after a code. >>> So I need to change CRLF (or LF) to CRLFCRLF. >>> >>> Which toool can I use for that, I can't remember which tool is a good >>> one for this and goo

Re: automated editing of text files

2011-09-16 Thread Tom Furie
On Fri, Sep 16, 2011 at 05:24:52PM +0200, Bonno Bloksma wrote: > linbobo:~/sedtest# sed 's_\n\n_\n\n\n_' new.txt > linbobo:~/sedtest# less new.txt You want to change the regexp here. In regular expressions '^' matches start of line and '$' matches end of line. Your sed instruction above should be

RE: automated editing of text files

2011-09-16 Thread Bonno Bloksma
Hi Camaleón, >> I have a bunch of files where I need an extra line after a code. >> So I need to change CRLF (or LF) to CRLFCRLF. >> >> Which toool can I use for that, I can't remember which tool is a good >> one for this and google is no help. >> I am not fluent in any of the programming langua

Re: automated editing of text files

2011-09-16 Thread Camaleón
On Fri, 16 Sep 2011 17:01:40 +0200, Bonno Bloksma wrote: > I have a bunch of files where I need an extra line after a code. > So I need to change CRLF (or LF) to CRLFCRLF. > > Which toool can I use for that, I can't remember which tool is a good > one for this and google is no help. > I am not f

automated editing of text files

2011-09-16 Thread Bonno Bloksma
Hi, I have a bunch of files where I need an extra line after a code. So I need to change CRLF (or LF) to CRLFCRLF. Which toool can I use for that, I can't remember which tool is a good one for this and google is no help. I am not fluent in any of the programming languages but I do write bash scr