| | |
delete line + next line, if word match
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Dec 2008
Posts: 8
Reputation:
Solved Threads: 0
hi, i hope someone can help here with my problem.
i have a file with this structure:
testtt Login-Lat-Group = CNAme
Auth-Type = whatever
testt Login-Lat-Group = CName
Auth-Type = whatever
test Login-Lat-Group = CName
Auth-Type = whatever
i need now a command (e.g. awk or sed) which deletes the whole line containing the name, plus next line. but it must be exact match, deleting "test " must not end up in deleting all lines including "test" like "testt" or "testtt"
thanks in advance for any help
br, Pender
i have a file with this structure:
testtt Login-Lat-Group = CNAme
Auth-Type = whatever
testt Login-Lat-Group = CName
Auth-Type = whatever
test Login-Lat-Group = CName
Auth-Type = whatever
i need now a command (e.g. awk or sed) which deletes the whole line containing the name, plus next line. but it must be exact match, deleting "test " must not end up in deleting all lines including "test" like "testt" or "testtt"
thanks in advance for any help
br, Pender
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Hey There,
You can catch tabs with sed using escape characters. So far tabs, you could match it with:
Hope that helps and best wishes,
Mike
You can catch tabs with sed using escape characters. So far tabs, you could match it with:
•
•
•
•
s '/test\t/d' <file
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
•
•
[...]
i need now a command (e.g. awk or sed) which deletes the whole line containing the name, plus next line. but it must be exact match, deleting "test " must not end up in deleting all lines including "test" like "testt" or "testtt"
•
•
•
•
i have no clue how to match the regexp for a word, followed by tab
sed '/test/d' < file ....... will delete all lines
sed '/test /d' < file ...... will not find anything
how can i check for the followed tab?
\<word_here\> will do that. Once the pattern is matched, it deletes from that line to the end of the following one. bash Syntax (Toggle Plain Text)
sed -e '/\<test\>/,/$/d' < filesource > filedestination
Last edited by Aia; Dec 13th, 2008 at 6:20 pm.
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Glad to hear it 
Best wishes to you,
Mike

Best wishes to you,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
![]() |
Similar Threads
- arg loops!!!!! (Python)
- PLS I NEED YOUR HELP! Help on Reading and Editing of already Written CODE on php! (PHP)
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
- Debug assertion failed (C++)
- while loop dont seem to work (C++)
- Open In New Window Php (PHP)
Other Threads in the Shell Scripting Forum
- Previous Thread: integer division! oh the fun :-)
- Next Thread: Random Number Korn
| Thread Tools | Search this Thread |






