However in practice we need to remove some text from a file or from multiple files. Removing text from files manually is a tough task. Here is a sample example to do this:
Create a script
- Create a file like
- Write following lines of code in that file
You can use any extension in place of txt according to your requirement.
grep -v "YOUR_TEXT_TO_REMOVE" $thefile > $thefile.$$.tmp returns the content of all
.txt files in that directory
YOUR_TEXT_TO_REMOVE and write that output in a tempfile then
replace new file with that original one.
- To run script just run