Dasoren Dasoren - 2 months ago 17
Linux Question

Linux, Print all lines in a file, NOT starting with

I would like to print the contents of a file, but all lines starting with # I want to ignore. I was trying some stuff with grep and awk, but it kept printing the whole file, or just printed the lines starting with #. I you could give me a push in the right way, or a grep/awk command that would print anyline in the file that does not start with #.

Answer Source

Use the -v option of grep to negate the condition:

grep -v '^#' file