howto remove a particular phrase from a text file?
i need to remove a little piece of text from a bigger text file. i can find the phrase with grep, but have no idea howto remove it from the file.
any advice appreciated. |
Hi,
Sed can do that: sed -i 's/to be removed//' infile The above will remove to be removed from the infile and saves it in place (the i- option). Try without the -i option first, output is printed to screen instead. Hope this helps. |
could be done with grep,
Code:
cat infile | grep -v [phrase] > outfile |
Hi,
True, grep can also remove, but it takes out the whole line, not a part of that line. Depending on what you want, both can be used. BTW: Use: grep -v "[phrase]" infile > outfile if the grep statement is preferable, it's more resource friendly (only one command instead of 2). |
This solves the issue. Thank you very much :)
|
All times are GMT -5. The time now is 09:02 PM. |