# Syntax Error while using CMP function

**URL:** <https://community.unix.com/t/syntax-error-while-using-cmp-function/315213>\
**Category:** Shell Programming and Scripting\
**Created:** [August 15, 2012, 4:06pm UTC](https://community.unix.com/t/syntax-error-while-using-cmp-function/315213 "2012-08-15T16:06:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsfreddie](https://community.unix.com/letter_avatar/dsfreddie/32/6_449c533f586939b6e5f246632a46421f.png) [@dsfreddie](https://community.unix.com/u/dsfreddie)\
**Post date:** [August 15, 2012, 4:06pm UTC](https://community.unix.com/t/syntax-error-while-using-cmp-function/315213/1 "2012-08-15T16:06:14Z")

</div>

Hi All,

I am getting a syntax error message while trying to compare 2 files using the compare function (LINUX)

> [@](#):
>
> cmp -s \<(tr , [\\n](file://n/) \< $COMMON\_TMP/nt\_per\_gs.done | sort) \<(tr , [\\n](file://n/) \< $COMMON\_TMP/nt\_per\_chg\_indx.done | sort)

command substitution: line 79: syntax error near unexpected token `('  
command substitution: line 79: `cmp -s \<(tr , \n \< $COMMON\_TMP/nt\_per\_gs.done | sort) \<(tr , \n \< $COMMON\_TMP/nt\_per\_chg\_indx.done | sort)'  
+ file\_cmp\_chk=1

The return value should be 0 as both the .done file contain the same dates. (like below)

> [@](#):
>
> $ cat /iis\_dev\_data3/wcc/cpmg/tmp/wcc\_cpmg\_nt\_per\_chg\_indx.done  
> 20120708,20120707
> 
> $cat /iis\_dev\_data3/wcc/cpmg/tmp/wcc\_cpmg\_nt\_per\_gs.done  
> 20120708,20120707

Can you pls help to fix this issue

Thanks  
Freddie

---

<div class="post-metadata">

**Author:** ![Chubler\_XL](https://community.unix.com/user_avatar/community.unix.com/chubler_xl/32/2077_2.png) [@Chubler\_XL](https://community.unix.com/u/Chubler_XL)\
**Post date:** [August 15, 2012, 4:48pm UTC](https://community.unix.com/t/syntax-error-while-using-cmp-function/315213/2 "2012-08-15T16:48:55Z")

</div>

What shell are you using to run your script?

Process subsitution is typically a bash thing, make sure you have `#!/bin/bash` at the top of your script, and that the OS supports named pipes.

---

<div class="post-metadata">

**Author:** ![dsfreddie](https://community.unix.com/letter_avatar/dsfreddie/32/6_449c533f586939b6e5f246632a46421f.png) [@dsfreddie](https://community.unix.com/u/dsfreddie)\
**Post date:** [August 15, 2012, 6:29pm UTC](https://community.unix.com/t/syntax-error-while-using-cmp-function/315213/3 "2012-08-15T18:29:32Z")

</div>

Thanks Chubler for your reply.

The script is ksh (LINUX i.e #!/bin/ksh). I could see the same commands are working in one script, but not in this one. Not able to figure out the issue (Did comparison too)😕

Thanks Much  
Freddie

---

<div class="post-metadata">

**Author:** ![methyl](https://community.unix.com/letter_avatar/methyl/32/6_449c533f586939b6e5f246632a46421f.png) [@methyl](https://community.unix.com/u/methyl)\
**Post date:** [August 15, 2012, 7:00pm UTC](https://community.unix.com/t/syntax-error-while-using-cmp-function/315213/4 "2012-08-15T19:00:40Z")

</div>

LINUX is a vague description of a huge range of unix-like Operating Systems.  
Which Operating Systems and versions are you actully running?

Your might be because you have one system with the original ksh and another system with something later like ksh93.

---

<div class="post-metadata">

**Author:** ![dsfreddie](https://community.unix.com/letter_avatar/dsfreddie/32/6_449c533f586939b6e5f246632a46421f.png) [@dsfreddie](https://community.unix.com/u/dsfreddie)\
**Post date:** [August 19, 2012, 6:27pm UTC](https://community.unix.com/t/syntax-error-while-using-cmp-function/315213/5 "2012-08-19T18:27:01Z")

</div>

Hi Methyl,

Pls find below the LINUX OS version,

> [@](#):
>
> Linux [XXXXXXXXX.XXXXXXXXXXX.com](http://XXXXXXXXX.XXXXXXXXXXX.com) 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86\_64 x86\_64 x86\_64 GNU/Linux

Also, i tried with #!/bin/bash. It didnt work either.

I have used the same command in another LINUX script & it works fine. Tried copying the same line to this script & tried execting, but it still throws syntax error.

Any help will be really helpful.

Thanks,  
Freddie

---

<div class="post-metadata">

**Author:** ![methyl](https://community.unix.com/letter_avatar/methyl/32/6_449c533f586939b6e5f246632a46421f.png) [@methyl](https://community.unix.com/u/methyl)\
**Post date:** [August 19, 2012, 7:42pm UTC](https://community.unix.com/t/syntax-error-while-using-cmp-function/315213/6 "2012-08-19T19:42:52Z")

</div>

Moderator comments were removed during original forum migration.
