Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

filter with grep to print when text is NOT present in another file

I have a linux filter to extract all lines from an xcode project that contain localized strings and produce a sorted list of unique entries. The filter works fine and is shown below.

grep NSLocalized *.m | perl -pe 's/.*NSLocalizedString\((.+?)\,.*/$1/' | sort | uniq 

The result is a list of strings looking like this

@"string1"
@"string2"
etc

What I now need to do is identify the entries that do not exist within another textfile. So imagine I have a text file containing;

@"string1"
@"string3"
etc

The result would be @"string2" as it is not present in the file

For the sake of argument, the file is named list.txt

What do I need to add to my filter? I'm sure I can do this with grep but my brain has failed!

like image 411
Roger Avatar asked Dec 12 '22 19:12

Roger


1 Answers

a Simple GREP switch (-v) prints the inverse. So the command would be

GREP -v -f filename1 filename2 > filename3

like image 70
Konark Modi Avatar answered Dec 28 '22 22:12

Konark Modi