[Wolves] Sed help.

Simon C. Burke simonb at geek-web.co.uk
Fri Jun 20 12:06:53 BST 2008

----- Original Message ----- 
From: "Ron Wellsted" <ron at wellsted.org.uk> 
To: "Wolverhampton Linux User Group" <wolves at mailman.lug.org.uk> 
Sent: Friday, 20 June, 2008 11:41:18 AM GMT +00:00 GMT Britain, Ireland, Portugal 
Subject: Re: [Wolves] Sed help. 

On Fri, Jun 20, 2008 at 11:28:48AM +0100, Simon C. Burke wrote: > In the end I replaced the sing quotes with double quotes and escaped them with the good old backslash. > Now I just need to find how to add tot he start. > > > ----- Original Message ----- > From: "Simon C. Burke" > To: wolves at mailman.lug.org.uk > Sent: Friday, 20 June, 2008 11:11:20 AM GMT +00:00 GMT Britain, Ireland, Portugal > Subject: [Wolves] Sed help. > > > I have a text file with some 18000 lines and i need to ammend something to the start and end. For the end I have: > > sed 's/$/Add Text to end"/g' myfile > > However the text I'm adding is: > > ' |grep -vir 'http://' >> test.txt > > > The issue I have is that how do I now escape the pipe and inverted comma's? > > Any idea's?? Glad you found a solution to your first problem There was an simpler solution : use a script file which you invoke with the -f switch (eg sed -f script.sed infile >outfile) This way you do not need to worry about shell escapes. The normal RE char for the begining of a line is the caret ^ HTH 

Thanks for that. I worked it out in the end, awk's a bit alien to me at the moment. so im really happy with what I have done so far. 
The next issue was echoing an incrementing number into test.txt (ie test2.txt, test3.txt) and so forth. I was going to cheat and instead of awking the text to the end, still awk the front ut use a quick bash script to echo the end with the variable in. Ah well the scripts running now. 

Thanks for any time anyone spent on this. 


Simon B 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.lug.org.uk/pipermail/wolves/attachments/20080620/3e394a23/attachment-0001.html

More information about the Wolves mailing list