Use the beginning of the line and quotation marks:
cat file.txt | egrep -v '^P.*'
P* means P zero or more times, so no lines are highlighted with -v
^P.* means the beginning of the line, then P and any char zero or more times
A quote is required to prevent shell expansion.
It can be shortened to
egrep -v ^P file.txt
because .* not required, so quoting is not required, and egrep can read data from a file.
Since we do not use extended regular expressions, grep also works great.
grep -v ^P file.txt
Finally
grep -v ^P file.txt > new.txt
Grzegorz Żur
source share