Sed one liners to display line ranges
Display all lines from file except lines between two lines matching a pattern:
1 | sed '/10\/02\/1992/,/01\/02\/2001/d' input.txt |
Display lines between two lines matching a pattern:
1 | sed -n '/10\/02\/1992/,/01\/02\/2001/p' input.txt |
Display all lines from file, excluding a line range between 2 and 90:
1 | sed 2,90d input.txt |
Display only lines between line numbers 2 and 90:
1 | sed -n 2,90p input.txt |
Display line two:
1 | sed -n 2p input.txt |
Leave a comment