comm command -- Sort and compare two files

Team,

I have two files and I am trying to find the lines unique to file1. So i have executed the below command at shell prompt and got the correct results

 
comm -23 <(sort test) <(sort test1)

When i run the same command in Bash shell script, i got the correct results.
But when i run the same command in Korn shell script, i am getting syntax error.

Error: syntax error: `(' unexpected

Can you let me know the the correct syntax in Korn Shell or is there any way to execute the command alone in bash shell and the rest of the script in Korn.

Works for me even on a fairly old version of Kshell (Version JM 93t+ 2009-02-02). What version of ksh do you have?

You can run echo "${.sh.version}" or ksh --version at the command line to show the version.

I tried below three commands. None returned the verion. Output of $KSH_VERSION is blank

ksh --version

ksh: ksh: --: unknown option

echo "${.sh.version}"

bash: ${.sh.version}: bad substitution

echo $KSH_VERSION

How about uname -a

And rather than executing the echo from a bash prompt, try this:

ksh -c "echo ${.sh.version}"
1 Like

Try the old way:

sort <test >test.sor
sort <test1 >test1.sor
#
comm -23  test test1
#
rm test.sor
rm test1.sor

Ps. It is not advisible to call a file the same name as a unix command. In this case "test".

Pps. For an older ksh, the version is displayed by:
Esc K ^V
(Escape K Ctrl/V)