I have a file. I want to select the lines that does not start with www.
and does not contains slashes. I want to output the result into result.txt
To achieve the first requirement:
grep -v '^www\.' myfile.txt > result.txt
.
To achieve the second, I will take result.txt and execute:
grep -v '/' result.txt > result2.txt
Is there any better shorcut to execute several commands on the file and store the result into one output file: result.txt
I am aware of |
to execute several commands where the output of the command on the left of |
is input of the command in the right of |
. What I do not know is, in case of grep or any other command, should I use the file name in the command on the right of |
. In other words, should it be:
grep -v '^www\.' myfile.txt | grep -v '/' > result.txt
OR
grep -v '^www\.' myfile.txt | grep -v '/' mfile.txt > result.txt