I\'m trying to match a pattern from piped input and/or a file, and then remove from the matched lines to the end of the file, inclusive. I\'ve looked everywhere, but can\'t
why not
sed '/^-----THIS STUFF IS USELESS-----$/,$d' file
In a range expression like you have used, ',$' will specify "to the end of the file"
1 is first line in file,
$ is last line in file.
output
Files:
somefiles.tar.gz 1 2 3
somefiles.tar.gz 1 2 3
With GNU sed
, you can do
sed '/^-----THIS STUFF IS USELESS-----$/Q' file
where Q
is similar to q
quit command, but doesn't print the matching line