![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Finding difficult in installing gcc-3.4.6 complier on Solaris 10. | susainaj | SUN Solaris | 4 | 07-11-2008 11:35 AM |
| so difficult question about using grep | shrimpy | UNIX for Dummies Questions & Answers | 2 | 03-22-2008 12:19 AM |
| A difficult script (for me) | DNAx86 | Shell Programming and Scripting | 2 | 01-07-2008 04:04 PM |
| difficult time differences | Lokesha | SUN Solaris | 1 | 06-20-2006 11:42 AM |
| Difficult Filtering Problem | Piyush | UNIX for Advanced & Expert Users | 1 | 06-30-2003 05:06 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
difficult sed command
Im trying to replace every line
line1 line2 line3 with: line1 extraline1 line2 extraline2 line3 extraline3 with about 10 extra lines I am able to add axtra lines with: sed '/[^ ]*/ a\\ new line\\ ' file > newfile but i want the name of the original line in the new lines, I have tried using '&' eg: sed '/[^ ]*/ a\\ extra&\\ ' file > newfile but it outputs the & symbol and not the original line! Can anyone help me? |
|
||||
|
Thanks, that works for the first line, but i want to create a second line with the first line in it. And the following code doesnt work.
sed -e 's/\(.*\)/\1\nextra\1/' -e '/\(.*\)/ a\\ nextra\1\nextra/1/\\ ' test > temp The result is: filename1.ADFnextrafilename1.ADF nextra1nextra/1/ Can you help? |
|
||||
|
Quote:
Alternative in Python: Code:
>>> extralines = ['extraline1','extraline2','extraline3']
>>> lines = ['line1','line2','line3']
>>> zip(lines,extralines)
[('line1', 'extraline1'), ('line2', 'extraline2'), ('line3', 'extraline3')]
>>> for i in zip(lines,extralines):
... print '\n'.join(i)
...
line1
extraline1
line2
extraline2
line3
extraline3
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|