Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SED to insert text into file

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
I have a file with multiple lines just like below:

beaster1
beaster2
beaster3
beaster4

I need to use sed to insert exactly the text below into the beginning of each line:

/opt/tmos/bin/ops_nui -file /home/bham_mta/rehome_scripts/

and it would > to file command_2 and look like below:

/opt/tmos/bin/ops_nui -file /home/bham_mta/rehome_scripts/beaster1
/opt/tmos/bin/ops_nui -file /home/bham_mta/rehome_scripts/beaster2 (and so on)

I tried:
sed -e 's/^/opt/tmos/bin/ops_nui -file /home/bham_mta/rehome_scripts/g' command_1 > command_2

and I keep getting the below so I don't think it is taking the "/" literally. Please help, it says command garbled!

sed: command garbled: s/^/opt/tmos/bin/ops_nui -file /home/bham_mta/rehome_scripts/g
 
All on one line - the posting might be wrapped:

sed -e 's:.*:/opt/tmos/bin/ops_nui -file /home/bham_mta/rehome_scripts/&:g' command_1 > command_2

NOTE: my suggestion on the AWK forum didn't work, eh? ;) vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
I am very sure it would have worked perfectly as always, but for my simple mind, I had to think of the easiest way for me to keep pursuing getting this done instead of bothering all of you genius's!!! I had some sed stuff that has worked in the past, so I thought to go with that.

You guys are the best, thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top