Hi,
I have a Master file (file.txt) with good and bad records( records with unicode characters). I ahve a file with only bad records (bad.txt)
I want the records in file.txt which are not present in bad.txt ie only the good records.
I tried
comm -23 file.txt bad.txt
It is giving all the records in file.txt.
Any help??
you need paste the sample of master file and bad records file
Take this as example.. a1 is master file and a2 is bad record file.My output should be
9
8
6
4
2
$ cat a1
9
8
7
6
5
4
2
3
$ cat a2
1
3
5
7
$ comm -23 a1 a2
9
8
7
6
5
4
2
3
drl
July 6, 2010, 8:01am
4
Hi.
Before `comm' can be used, the input files must be sorted
using the collating sequence specified by the `LC_COLLATE'
locale. If an input file ends in a non-newline character,
a newline is silently appended. The `sort' command with no
options always outputs a file that is suitable input to `comm'.
-- excerpt from info coreutils
Best wishes ... cheers, drl
Is there any way i can do it without sorting the file.The file is big.
find the different.
$ grep -v -f a2 a1
9
8
6
4
2
find the same records.
$ grep -f a2 a1
7
5
3
Getting the following error with grep -v -f
$ grep -v -f a2 a1
grep: illegal option -- f
Usage: grep -hblcnsviw pattern file . . .
grep -v a2 a1
this shud get u going..
u can use ur master and bad sector file and get the good records
lets say
master file = m, bad record=b
cat m > result
cat b >> result
uniq -u result
this will only give u good results.
-u Displays only lines not duplicated (uniq lines).
Assuming each record is unique and that the output order does not matter:
cat file.txt bad.txt | sort |uniq -u
Or sort each file before the "comm".
cat file.txt | sort >file.sor
cat bad.txt | sort >bad.sor
comm -23 file.sor bad.sor
dazdseg:
grep -v a2 a1
This should get you going..
You can use your master and bad sector file and get the good records.
...
This will only give you good results.
There, now you know the real words.
@corona :Thats what dazdseg told rite.. Did you add anything to it...
thanks for letting me know.
Please don't use 'l33t sp33k' - this isn't twitter. Plain English. If English is a problem for you we have translation services. That is what corona is telling you.
I will remember that as well since i am new to the forum.