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
-
grepis a linux command that print lines that match given patterns -
-vis 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)
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
-
grepis a linux command that print lines that match given patterns -
-vis 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 |
|---|---|---|---|---|
| 0 | 12733 | en | https://en.ans.wiki/477/on-linux-how-to-cat-a-file-excluding-lines-starting-with-a-given-string | 5 |
Icons proudly provided by Friconix.