![]() |
Sed, insert string to the beginning of a line
Hello,
I would need to add a specific string to the beginning of every line in a document which contains an other specific string, by using Sed or Awk. I've tried my best to figure out this myself by using examples and tutorials, but I cant find any documentation about this. I did find out how to add something to the beginning of every line (s/^.*/text-to-add/ ), but I didn't manage to convert that so that it would work as i need it. Ie. If a line contains the string <AB>, i would like to add a the text 'CDE' to the very beginning of that same line. Im using Sed for Windows, but I asume the commands are almost the same as for Linux. Thank you in advance, Ken2 |
awk solution:
:
awk ' {if(/AB/) :
AB:
CDEAB |
Thank you very much :)
|
| All times are GMT -5. The time now is 11:23 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC