Hi,
vi test.txt
Now when I execute the command,Code:sun sun moon star moon
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
| SitePoint Sponsor |


Hi,
vi test.txt
Now when I execute the command,Code:sun sun moon star moon
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
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
Bookmarks