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

btw: between the word to search (eg. test) and "Login-Lat-Group" is a TAB. so searching for "test<blank>" wont give the match

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?

Hey There,

You can catch tabs with sed using escape characters. So far tabs, you could match it with:

s '/test\t/d' <file

Hope that helps and best wishes,

Mike

[...]
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?

sed needs to be told that test is not a substring but a word: \<word_here\> will do that. Once the pattern is matched, it deletes from that line to the end of the following one.

sed -e '/\<test\>/,/$/d' < filesource > filedestination

thank you aia & eggi. you helped a lot.

Glad to hear it :)

Best wishes to you,

Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.