Hi,
vi test.txt
sun
sun
moon
star
moon
Now when I execute the command,
cat test.txt | grep sun > sun.txt
text “sun” is copied to a file.
I need a help how to delete the lines which has “sun” from text.txt and save the file
Hi,
vi test.txt
sun
sun
moon
star
moon
Now when I execute the command,
cat test.txt | grep sun > sun.txt
text “sun” is copied to a file.
I need a help how to delete the lines which has “sun” from text.txt and save the file
Use grep’s inverse option and redirect back into the file:
cat test.txt | grep -v sun > test.txt
Cheers,
D.
To sum up:
cat test.txt | grep sun > sun.txt && cat test.txt | grep -v sun > test.txt