You can do it with sed
:
sed '1,/^::remove txt before this line::$/d' source.txt
How it works
sed
reads the content of the source.txt
file line by line and applies the script provided in the first argument to each line.
The program above is very simple; it contains only one command: d
(delete). The command applies to the rows that match the addresses provided in front of the command.
The d
command above is provided two addresses: 1
and /^::remove txt before this line::$/
.
1
means the first line of the file.
/^::remove txt before this line::$/
is a regular expression that matches the line(s) that contain exactly the string ::remove txt before this line::
(^
matches the beginning of the line, $
matches the end of the line).
The sed
command above reads all the lines from the input file and removes (doesn't display) the starting with the first line of the file until (and including) the first line that contains only the text ::remove txt before this line::
. All the other files are displayed on its output (it doesn't change the input file).
If there is no matching line in the input file, the command doesn't display anything.