Combine several text files into a single one
cat file1 file2 file3 > newfile
Add more files to an existing document
cat file1 file2 file3 >> destfile
Delete lines in a text file that containing a specific string
grep -v “pattern” filename > filename2; mv filename2 filename
You can use grep. Lets say you want search in the file source_file , and the second file where you have the lines that you want to search from is input_file. Use
grep -f input_file source_file > output_file
Let’s say your source_file is
Humpty Dumpty sat on a wall
Humpty Dumpty had a great fall
All the King's horses and
All the Queen's men
COuld not put Humpty together again
And input file is
Humpty
Queen
The your output fie would be
Humpty Dumpty sat on a wall
Humpty Dumpty had a great fall
All the Queen's men
COuld not put Humpty together again