![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need to replace the first word of a line if it occurs again in the next line(shell) | geeko | Shell Programming and Scripting | 4 | 06-18-2009 03:36 PM |
| search for a string ,replace the whole line with new line | kkraja | Shell Programming and Scripting | 4 | 08-07-2008 03:26 AM |
| How to replace a line | ukatru | Shell Programming and Scripting | 2 | 08-04-2008 03:51 PM |
| How to replace one line with three in sed | ch0sen | Shell Programming and Scripting | 6 | 03-05-2008 12:08 PM |
| sed - Replace Line which contains the Pattern match with a new line | kousikan | Shell Programming and Scripting | 2 | 03-24-2007 07:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
i want to replace some lines in a file "Source.txt" by taking search pattern input from a different file named "abc". Search pattern input file have following lines: vi abc 2637918 2707239 2709124 2709148 2709159 2709177 ........... i am running following code: for i in `cat abc` ;do perl -pi.bk4 -e 's/^.*$i.*//g' Source.txt;done but it's not working....... pls help. |
|
||||
|
You want to replace them with empty lines, or delete them? Delete is easy: Code:
fgrep -vf abc Source.txt For replacing with nothing, perhaps the following: Code:
sed -e 's%.*%s/.*&.*//%' abc | sed -f - Source.txt Maybe your sed can't handle standard input for the -f option; if so, report back here and we'll think about workarounds. Repeated looping over all the input patterns seems awfully inelegant and inefficient. |
|
||||
|
Hi Vidya,
ur sed commnd is replacing the input seach pattern line with nothing but.... size of output file is getting 3 times more than the orignal file.... means each time after replacing the matched line with nothing the command is adding the entire file into the output file again.... pl help anybody.......hw to overcome this problem... |
|
||||
|
Quote:
Input: Quote:
Quote:
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|