Wednesday, September 26, 2012

Remove lines in one file from another file: UNIX

ISSUE:
some config file need be updated to remove no-need lines. the no-need lines were provided without any sort.

SOLUTION:
a. put the no-need lines to a file - noneedfile
b. make a backup file of original one-  originfile.bkp
c. run
grep -v -x -f noneedfile originfile.bkp > originfile

CHECK:
cat noneedfile | wc -l
+
cat originfile | wc -l
=
cat originalfile.bkp | wc -l

Reference:

http://stackoverflow.com/questions/4780203/deleting-lines-from-one-file-which-are-in-another-file
http://www.unix.com/shell-programming-scripting/89798-compare-two-files-remove-all-contents-one-file-another.html


No comments:

Post a Comment