Quantcast
Channel: How to remove multiple lines per occurrence in a file? - Unix & Linux Stack Exchange
Browsing latest articles
Browse All 3 View Live

Answer by Jander for How to remove multiple lines per occurrence in a file?

The following will work on non-GNU sed (the ,+1 address syntax is a GNU extension): sed -e '/^a1$/,/^/d' my_file >my_filtered_file "Starting at a line that reads exactly 'a1', and ending at the next...

View Article



Answer by asoundmove for How to remove multiple lines per occurrence in a file?

Try: sed -e '/^a1$/,+1d' "filename" This means from /^a1$/ to the next line, delete The ^ and $ ensure you match the whole line, so a hidden a1 will not be matched.

View Article

How to remove multiple lines per occurrence in a file?

Say I have this 857835 line file, containing stuff like this: a1 rubbish1 rubbish2 rubbish3 rubbish4 a1 rubbish5 rubbish6 rubbish7 rubbish8 And I wish to remove all occurences of a1 and the next line...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images