From: Mike Jones on 2 Aug 2010 19:24 I have a long file with more lines than I fancy manually editing, and need to cut all the added comments from any lines that have them. ie: line1 line2 # comments line3 line4 # with notes line5 # more stuff ....becomes line1 line2 line3 line4 line5 Anybody got quick'n'simple technique for this kind of thing? XP alt.os.linux,alt.os.linux.slackware FU alt.os.linux -- *=( http://www.thedailymash.co.uk/ *=( For all your UK news needs.
From: J.O. Aho on 2 Aug 2010 19:54 Mike Jones wrote: > > > I have a long file with more lines than I fancy manually editing, and > need to cut all the added comments from any lines that have them. > > ie: > > line1 > line2 # comments > line3 > line4 # with notes > line5 # more stuff > > ...becomes > > line1 > line2 > line3 > line4 > line5 > > Anybody got quick'n'simple technique for this kind of thing? Something like: sed 's/\([a-zA-Z0-9]*\)#.*/\1/g' -i file don't forget to make a backup before you test. -- //Aho
From: ray on 2 Aug 2010 20:19 On Mon, 02 Aug 2010 23:24:21 +0000, Mike Jones wrote: > I have a long file with more lines than I fancy manually editing, and > need to cut all the added comments from any lines that have them. > > ie: > > line1 > line2 # comments > line3 > line4 # with notes > line5 # more stuff > > ...becomes > > line1 > line2 > line3 > line4 > line5 > > Anybody got quick'n'simple technique for this kind of thing? > > > > XP alt.os.linux,alt.os.linux.slackware FU alt.os.linux 'cut' should work quite nicely.
From: stuart on 3 Aug 2010 03:13 Mike Jones wrote: > > I have a long file with more lines than I fancy manually editing, and > need to cut all the added comments from any lines that have them. > > ie: > > line1 > line2 # comments > line3 > line4 # with notes > line5 # more stuff > > ...becomes > > line1 > line2 > line3 > line4 > line5 > > Anybody got quick'n'simple technique for this kind of thing? Load the file into vi and do command :%s/#.*\n/^M/g and all those comments disappear. I get that ^M by doing Ctrl+v Ctrl+m Stuart
From: Martin on 3 Aug 2010 03:54 On 08/03/2010 12:24 AM, Mike Jones wrote: > line1 > line2 # comments > line3 > line4 # with notes > line5 # more stuff > > ...becomes > > line1 > line2 > line3 > line4 > line5 Try the following. That is assuming that your comments # is the first # on each line: sed -e 's/\(.*[^#]\)\(#.*\)/\1/' file.txt regards Martin
|
Next
|
Last
Pages: 1 2 3 Prev: odd results using tar to do a full system backup .... more Next: My 3rd sata drive |