05-09-2006
comm command in sorting IP
i have 2 files that contains a sorted list of IP addresses.
file_A contains a list of all IPs
file_B contains only around 50% of what is in file_A.
I tried to execute
comm -23 file_A file_B > file_C
to get the difference. My objective is to put all the IPs that are in file_A but not in file_B to file_C.
why am i still getting around 1-2 IPs that are still in file_B? i have sorted both files before executing the comm.
please help.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
See my other post on sdiff ....
I don't think sdiff is able to do what I want.
The 'comm' command does what I need and works fine as
far as the logic and results.
The problem I'm having is with the output format, it outputs 3 columns of data,
but because of the way it starts each line... (2 Replies)
Discussion started by: cowpoke
2 Replies
2. Shell Programming and Scripting
Hi
I have issue with "comm " command
file-1
----
l65059
l65407
l68607
l68810
l69143
l71310
l72918
l73146
l73273
l76411
file-2
----- (8 Replies)
Discussion started by: amitrajvarma
8 Replies
3. UNIX for Dummies Questions & Answers
Hi all,
I need help in comm command , I am having 2 files . I have to display the common line in the two file only onnce and i have to also display the non common line as well.
tmpcut1 -- First file
cat tmpcut1
smstr_303000_O_432830_... f_c2_queue_sys30.sys30 RUNNING 10 1000... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies
4. Shell Programming and Scripting
Hi,
Hope someone can shed some light on this...
I have two lists of numbers I am comparing using COMM. If the first list is empty, and I sort both lists like so:
DIFF=`comm -3 <(echo "$EMPTY" | sort -n) <(echo "$NUMBERS" | sort -n)`I get the error: comm: file 2 is not in sorted order
But... (2 Replies)
Discussion started by: LostInTheWoods
2 Replies
5. Shell Programming and Scripting
I tried to compare two sorted files with comm command which contain floating values as:
RECT 0 9.8 8.70 7.8 in first file & RECT 0 9.80 8.7 7.80 in second file.
comm -3 first_file second_file should give a empty file but it does not.
Is there a way to compare these two files correctly... (4 Replies)
Discussion started by: nehashine
4 Replies
6. UNIX for Dummies Questions & Answers
could some one please explain with examples how comm -12 & comm -3 works. I am confused with manual page, Thankyou. (2 Replies)
Discussion started by: Ariean
2 Replies
7. Shell Programming and Scripting
I need to compare 2 files. I need to see if 1 file has records that are not in a second file. I did some searching and found the 'comm' command. According to the man pages
comm -23 test1.txt test2.txt
Will tell me what is in file 1 and not in file 2. So I did a simple test
test1.txt has the... (3 Replies)
Discussion started by: guessingo
3 Replies
8. UNIX for Dummies Questions & Answers
Hello , I am trying to get contents which are only present in a.csv ,so using comm -23
cat a.csv | sort > a.csv
cat b.csv | sort > b.csv
comm -23 a.csv b.csv > c.csv.
a.csv
SKU COUNTRY CURRENCY PRICE_LIST_TYPE LIST_PRICE_EFFECTIVE_DATE
TG430ZA ZA USD DF ... (4 Replies)
Discussion started by: RaviTej
4 Replies
9. Linux
The manual does not cover this very well. What do the following compares will do ?
1) comm -13 file1 file2: will it display what is in file2 not in file1?
2) comm -23 file1 file2: will it display what in 1 but not in 2 ?
Thanks (5 Replies)
Discussion started by: mrn6430
5 Replies
10. Shell Programming and Scripting
Hello all ,
I have two files a.txt and b.txt which have same content . They contain data that is fetched from database through a java program. When I delete a line in a.txt and run the below command
comm -13 a.txt b.txt
I am not getting the expected result i.e. the line i deleted from... (5 Replies)
Discussion started by: RaviTej
5 Replies
comm(1) General Commands Manual comm(1)
NAME
comm - Compares two sorted files.
SYNOPSIS
comm [-123] file1 file2
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
command: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
Suppresses output of the first column (lines in file1 only). Suppresses output of the second column (lines in file2 only). Suppresses
output of the third column (lines common to file1 and file2).
The command comm -123 produces no output.
OPERANDS
A pathname of the first file to be compared. If file1 is a hyphen (-), the standard input is used. A pathname of the second file to be
compared. If file2 is a hyphen (-), the standard input is used.
If both file1 and file2 refer to standard input or to the same FIFO special, block special or character special file, the results are unde-
fined.
DESCRIPTION
The comm command reads file1 and file2 and writes three columns to standard output, showing which lines are common to the files and which
are unique to each.
The leftmost column of standard output includes lines that are in file1 only. The middle column includes lines that are in file2 only.
The rightmost column includes lines that are in both file1 and file2.
If you specify a hyphen (-) in place of one of the file names, comm reads standard input.
Generally, file1 and file2 should be sorted according to the collating sequence specified by the LC_COLLATE environment variable. (See
sort(1).) If the input files are not sorted properly, the output of comm might not be useful.
EXIT STATUS
Successful completion. Error occurred.
EXAMPLES
In the following examples, file1 contains the following sorted list of North American cities:
Anaheim Baltimore Boston Chicago Cleveland Dallas Detroit Kansas City Milwaukee Minneapolis New York Oakland Seattle Toronto
The second file, file2, contains this sorted list:
Atlanta Chicago Cincinnati Houston Los Angeles Montreal New York Philadelphia Pittsburgh San Diego San Francisco St. Louis
To display the lines unique to each file and common to the two files, enter: comm file1 file2
This command results in the following output: Anaheim Atlanta Baltimore Boston Chicago Cincinnati Cleveland Dal-
las Detroit Houston Kansas City Los Angeles Milwaukee Minneapolis Montreal New York Oakland Philadel-
phia Pittsburgh San Diego San Francisco Seattle St. Louis Toronto
The leftmost column contains lines in file1 only, the middle column contains lines in file2 only, and the rightmost column contains
lines common to both files. To display any one or two of the three output columns, include the appropriate flags to suppress the
columns you do not want. For example, the following command displays columns 1 and 2 only: comm -3 file1 file2
Anaheim
Atlanta Baltimore Boston
Cincinnati Cleveland Dallas Detroit
Houston Kansas City
Los Angeles Milwaukee Minneapolis
Montreal Oakland
Philadelphia
Pittsburgh
San Diego
San Francisco Seattle
St. Louis Toronto
The following command displays output from only the second column: comm -13 file1 file2
Atlanta Cincinnati Houston Los Angeles Montreal Philadelphia Pittsburgh San Diego San Francisco St. Louis
The following command displays output from only the third column: comm -12 file1 file2
Chicago New York
SEE ALSO
Commands: cmp(1), diff(1), sdiff(1), sort(1), uniq(1)
comm(1)