Computing.Net > Forums > Unix > adding text to the end of every 2nd

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.

adding text to the end of every 2nd

Reply to Message Icon

Name: karl1
Date: December 14, 2006 at 06:46:14 Pacific
OS: cygwin
CPU/Ram: er
Product: erw
Comment:

hey,
how would i go about adding text to the end of every 2nd line, then appending the second line to the first? any help would be appreciated




Sponsored Link
Ads by Google

Response Number 1
Name: rais
Date: December 14, 2006 at 07:15:12 Pacific
Reply:

Half of this is:
gawk '{printf $0 ; if ((NR%2) == 0) {printf "\n"} }' YourFileName

Note: All above in one line.

Thanks.
The Network Department



0

Response Number 2
Name: karl1
Date: December 14, 2006 at 07:17:41 Pacific
Reply:

excellent thanks for that


0

Response Number 3
Name: karl1
Date: December 14, 2006 at 07:26:41 Pacific
Reply:

just 1 more thing, i have 2 instances of text ".dic>" on each line, i just need to substitute the last instance of this for "copy.dic" i have this so far

sed 's/dic>/copy.dic/' filename

but i dont know how to get the last instance on the line
please help


0

Response Number 4
Name: rais
Date: December 14, 2006 at 08:06:05 Pacific
Reply:

sed s/"dic>"/DDDD/ | sed s/"dic>"// | sed s/DDDD/"dic>"

Hope this helps.
Thanks.


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: adding text to the end of every 2nd

Adding variable at end of the row www.computing.net/answers/unix/adding-variable-at-end-of-the-row/7466.html

Inserting a string at the end of a www.computing.net/answers/unix/inserting-a-string-at-the-end-of-a-/6205.html

SAMBA NT4 & HPUX11 www.computing.net/answers/unix/samba-nt4-amp-hpux11/5984.html