Computing.Net > Forums > Unix > Locating and appending text

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Locating and appending text

Reply to Message Icon

Name: lamos
Date: April 7, 2004 at 07:35:45 Pacific
OS: Linux
CPU/Ram: pent3/256
Comment:

Hi folks,

Can someone help me. I'd like to locate a character (@) in a text file and append a string of characters like "< yyyyyyy...y". For example in both sed and awk:

xxxxxxxxxxxxxx@ <yyyyyyyyy

Thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: aigles
Date: April 7, 2004 at 08:15:54 Pacific
Reply:


sed 's/@/@<yyyyyy/g' input_file

sed 's/@/&<yyyyyy/g' input_file

awk '{gsub(/@/,"@<yyyyyy"); print}' input_file

awk '{gsub(/@/,"&<yyyyyy"); print}' input_file

Jean-Pierre.



0

Response Number 2
Name: lamos
Date: April 7, 2004 at 09:58:54 Pacific
Reply:

Hi Jean,

More specifically:

the inserted string is </usr/iplanet/suitespot/
I am getting command garbled message.

Newbie..


0

Response Number 3
Name: aigles
Date: April 7, 2004 at 10:26:03 Pacific
Reply:

The problem comes from the character '/' in the replacement string.

For the sed commands, replace the delimitor '/' by another character that is not in the replacement string.
For example:

sed "s!@!&</usr/iplanet/suitespot/!g'

Jean-Pierre.


0

Response Number 4
Name: lamos
Date: April 7, 2004 at 10:42:06 Pacific
Reply:

Jean,

I added the ' instead of ". It works! Thx

sed "s!@!&</usr/iplanet/suitespot/!g'



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Locating and appending text

DETAILED UNIX HELP PLEASE!!! www.computing.net/answers/unix/detailed-unix-help-please/2573.html

Append a file www.computing.net/answers/unix/append-a-file/6342.html

Batch ftp download script & append www.computing.net/answers/unix/batch-ftp-download-script-amp-append/5292.html