|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello" to 5th column but from line 1 to line 200. & I want to add another text "goodbye" to 5th column of the same file from line 201 to 800 & another text "live" again to 5th column to the same file from line 801 to 1000. I know I can use sed to add a column to my file but I don't know how to tell sed to add this column to from line & to to line. Code:
$ sed 's/\(.*\) \(.*\) \(.*\) \/\1 \2 \3 \ Desired string/' input > output this will add my desired string to the 4th column in the right place but I don't know how to limit this to a specific range of lines. May be there is a way to do it in sed or may be awk? Any help will be very welcome. Thanks in advance, Ezy |
| Sponsored Links | ||
|
|
|
|||
|
Oh thanks a lot....this works perfectly fine & it seems fast enough to work with huge files.
Thanks a lot |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| extract a line from a file using the line number | grandtheftander | Shell Programming and Scripting | 7 | 01-22-2009 10:24 AM |
| Appending line number to each line and getting total number of lines | chiru_h | Shell Programming and Scripting | 2 | 03-25-2008 10:19 AM |
| Appending the line number and a seperator to each line of a file ? | pjcwhite | Shell Programming and Scripting | 4 | 03-21-2007 01:29 AM |
| Unix Script with line number at beginning of each line. | mascorro | Shell Programming and Scripting | 5 | 06-19-2006 05:34 PM |
| identifying duplicates line & reporting their line number | stresslog | UNIX for Dummies Questions & Answers | 5 | 04-24-2006 01:43 AM |