Urgent: Filtering a File

Hi all

I need to write a small shell script, where we have one Log file and another File 1 containing some tags in it.

My log file can have multiple tags in it which can be other than the ones that are part of File 1.

So I need to write a script that will run and test whether the tags present in Log file are same as the ones that are in file 1

If there are some other tags in Log file other than file 1 then we need to make a file 2 containing all the new tags that are not present in File1.

Please help me in writing this script as it is very urgent :frowning:

Regds,
Hitesh

See man pages of comm. See if it helps.

Hey man can u please elaborate a bit more on it ...

i am new to this forum :slight_smile:

Suppose file1 contains
1
2
3
4
5
6
7
and file2 contains
4
5
6
7
8
9
13
24
34
then

comm -12 prints lines common to two files.
comm -12 file1 file2
4
5
6
7
Check 'man comm'. Also remember comm works on sorted files.

Hi

thats so gr8 of u that u hv helped me by writing an example but now i hv understood that comm will give u the comm tags /numbers in the 2 files ....

but if i look at this example itself what i need now is that i need to create a new file file 3 that will hv all the tags/ numbers that do not belong to file 2 but are part of file 1....

so my file 3 should be like
1
2
3

Please help me a bit on this ...

thanx in advance

Check manual. Its all there. by the way, for your question -
comm -23 file1 file2 --> will give you lines in file1 and not in file2. You can redirect this output to a new file as required.
comm -23 file1 file2 >file3