Question #477   Submitted by Answiki on 05/20/2021 at 07:13:44 PM UTC

On Linux, how to cat a file excluding lines starting with a given string?

Answer   Submitted by Answiki on 05/20/2021 at 07:20:23 PM UTC

On Linux, you can output file content excluding lines starting with a given string with the grep command with option -v:

grep -v '^string_to_exclude' file.txt

  • grep is a linux command that print lines that match given patterns
  • -v is an option that invert the sense of matching (select non-matching lines)
  • '^string_to_exclude' is the pattern (regex) to exclude (^ means start of line)
2 events in history
Answer by Answiki on 05/20/2021 at 07:20:23 PM

On Linux, you can output file content excluding lines starting with a given string with the grep command with option -v:

grep -v '^string_to_exclude' file.txt

  • grep is a linux command that print lines that match given patterns
  • -v is an option that invert the sense of matching (select non-matching lines)
  • '^string_to_exclude' is the pattern (regex) to exclude (^ means start of line)
Question by Answiki 05/20/2021 at 07:13:44 PM
On Linux, how to cat a file excluding lines starting with a given string?
# ID Query URL Count

Icons proudly provided by Friconix.