I am a windows user having basic idea about LINUX and i encountered this command:
cat countryInfo.txt | grep -v "^#" >countryInfo-n.txt
After some research i found that cat is for concatenation and grep is for regular exp search (don't know if i am right) but what will the above command result in (since both are combined together) ?
Thanks in Advance.
EDIT: I am asking this as i dont have linux installed. Else, i could test it.
Short answer: it removes all lines starting with a #
and stores the result in countryInfo-n.txt
.
Long explanation:
cat countryInfo.txt
reads the file countryInfo.txt
and streams its content to standard output.
|
connects the output of the left command with the input of the right command (so the right command can read what the left command prints).
grep -v "^#"
returns all lines that do not (-v
) match the regex ^#
(which means: line starts with #
).
Finally, >countryInfo-n.txt
stores the output of grep
into the specified file.
It will remove all lines starting with #
and put the output in countryInfo-n.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With