comm not working

Hi

Sorry if this a repeat question,

I have the following two files. Both are sorted.

file1
----
CSCeb69473
CSCsg70355
CSCsj78917
CSCsj85065
CSCsl48743
CSCsl72823
CSCsl77748

file2
----

CSCsg39295
CSCsj78917
CSCsj85065
CSCsl72823
CSCsl77748

when I executed "comm -23 file1 file2". Its not showing correctly.

It should show me content in file1 which is not tere in file2. right?

Any idea, why?

Is it that both shud have same number of lines.

Let me know,

Amit

The command

comm -23 file1 file2 

gives me the following output

CSCeb69473
CSCsg70355
CSCsl48743

I hope this is correct. What is the output you get? Also try comm without any option

comm file1 file2

Thx kris,

I am getting the following output

> comm -23 file1 file2
CSCeb69473
CSCsg70355
CSCsj78917
CSCsj85065
CSCsl48743
CSCsl72823

You may be using a different version of comm. Check what

man comm 

says.

What unix are you working on? Also verify

which comm

I am working on Solaris ...SunOS 5.8

Hi.

The combination of bash and comm on Solaris 10 seems to work:

#!/usr/bin/env bash

# @(#) s1       Demonstrate results from comm.

#  ____
# /
# |   Infrastructure BEGIN

echo
set -o nounset

debug=":"
debug="echo"

## The shebang using "env" line is designed for portability. For
#  higher security, use:
#
#  #!/bin/sh -

## Use local command version for the commands in this demonstration.

set +o nounset
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1) comm
set -o nounset

echo

FILE1=data1
echo " Input file $FILE1:"
cat $FILE1

echo
FILE2=data2
echo " Input file $FILE2:"
cat $FILE2

# |   Infrastructure END
# \
#  ---

echo
echo " Results from processing:"
comm -23 $FILE1 $FILE2

exit 0

Producing

$ ./s1

(Versions displayed with local utility "version")
SunOS 5.10
GNU bash 3.00.16
comm - no version provided for /usr/bin/comm.

 Input file data1:
CSCeb69473
CSCsg70355
CSCsj78917
CSCsj85065
CSCsl48743
CSCsl72823
CSCsl77748

 Input file data2:
CSCsg39295
CSCsj78917
CSCsj85065
CSCsl72823
CSCsl77748

 Results from processing:
CSCeb69473
CSCsg70355
CSCsl48743

The same results were obtained on Linux 2.6.11 (Debian).

I would next look at the data so see if there are extra non-printing characters ... cheers, drl

I have had problems when sort obeyed my locale but comm did not, or they were used in different locales. Make sure they agree on the sort order. A good safety measure is to use an explicit locale when using commands which care about collation order.

LC_ALL=C sort
LC_ALL=C comm
LC_ALL=C join
etc

Hi, era.

I don't think I have noticed that problem, but it sounds like a good idea. Rather than specify it individually for each command, I'll use the set, export, and report LC_ALL in my demonstration script templates, at least for a while.

The general problem seems like it would often be masked in threads in the forum because copy / paste will not transfer non-printing characters ... cheers, drl