|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Could someone please tell me the command to deleting a line with a specific word and also deleting all lines below this line? I want this to be done without opening the file itself using SED in HP Unix.
e.g. I have a text file input.txt and with 4 lines of text below: John 123 A--G Chris 190 C--T Mat 098 F--K Mike 674 B--N Pat 838 L--U I want to delete the line which has string "098" and all lines below this line to look like the below: John 123 A--G Chris 190 C--T |
|
#2
|
|||
|
|||
|
Quote:
not really easy, in this case try sed '/space098space/,$d' inputfile >outputfile NOTA space is to replace by a space NOTA this works only in this case, assumed you want delete all after ' 098 ' |
|
#3
|
|||
|
|||
|
Thanks iribach!
It worked! |
|
#4
|
|||
|
|||
|
Could someone tell me how to make a Korn Shell to do the below:
I have the files below with the same format (different data) as mentioned previously and I want a shell to run "sed '/098/,$ d' filename" on all of the files in the directory. list20051001.txt list20051002.txt list20051003.txt ... list20051031.txt |
|
#5
|
|||
|
|||
|
Quote:
a) mkdir savedfiles b) cp list2005* savedfiles c) for file in list2005* do sed WHATyouWANT savedfiles/$file >$file done |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > SED help needed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|