Syntax Error while using CMP function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Syntax Error while using CMP function
# 1  
Old 08-15-2012
Syntax Error while using CMP function

Hi All,

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

Quote:
cmp -s <(tr , \\n < $COMMON_TMP/nt_per_gs.done | sort) <(tr , \\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)

Quote:
$ 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
# 2  
Old 08-15-2012
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.

Last edited by methyl; 08-15-2012 at 08:02 PM.. Reason: correct shebang line
# 3  
Old 08-15-2012
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)Smilie

Thanks Much
Freddie
# 4  
Old 08-15-2012
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.
# 5  
Old 08-19-2012
Hi Methyl,

Pls find below the LINUX OS version,

Quote:
Linux 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

Last edited by methyl; 08-19-2012 at 08:51 PM.. Reason: blot company name
# 6  
Old 08-19-2012
Moderator's Comments:
Mod Comment Multiple threads open on this subject.
Continued here:
https://www.unix.com/shell-programmin...it-script.html
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash function using variable in it syntax error

The below bash function uses multiple variables CODING, SAMPLE, SURVEY, andvariant in it. The user selects the cap function and details are displayed on the screen using the $SURVEY variable, the directory is changed to $SAMPLE and the samples.txt is opened so the user can select the sample to... (6 Replies)
Discussion started by: cmccabe
6 Replies

2. Shell Programming and Scripting

Function works, trigger causes syntax error, whats my fault??

Needing a hint. Creating that function called Meter my simple script works well. What I want now is to start the last four commented lines to include or trigger a reaction, if there are more than n lines in that .txt-file it shall display that message for example. But the interpreter says there is... (3 Replies)
Discussion started by: 1in10
3 Replies

3. UNIX for Dummies Questions & Answers

Problem syntax with user-defined function

Hi ! I got a script from Arabic to Roman numeral conversion - .comp.lang.awk, that I would like to modify to apply it on my input file. input ("|"-delimited fields): AAAAAA|1, 10, 13, 14, 25, 60 wanted output: AAAAAA|I, X, XIII, XIV, XXV, LX script.awk: #!/usr/bin/gawk -f ... (11 Replies)
Discussion started by: lucasvs
11 Replies

4. Shell Programming and Scripting

AWK Function syntax

Hi, I would like to know what is the correct syntax to perform a function in awk. Although I have seen several examples, not get it to work, this is what I'm trying: #!/bin/bash awk function multi (number) { return number * 3 } print multi (4)Thanks (2 Replies)
Discussion started by: Godie
2 Replies

5. Shell Programming and Scripting

KSH - different syntax for function

Hi, I wanted to know what's the difference between the below two syntax used for writing ksh function: e.g. 1 ------ function fn1 { echo "Hello World" } e.g. 2 ------ fn1 () { echo "Hello World" } (4 Replies)
Discussion started by: dips_ag
4 Replies

6. Solaris

cmp file

Dear all, for i in <List of Filename> FILENAME=`echo $i` do cp -p $FILENAME /temp /bin/cmp $FILENAME /temp/$FILENAME done I am planning to do something like this on a daily basis, so i want to ask that, if the comparison on the files encounter error, ... (2 Replies)
Discussion started by: beginningDBA
2 Replies

7. Shell Programming and Scripting

date cmp

Please don't count this as a similar post.....I got the ftp part working....I am stuck how to find the files between two dates. I have 5 files filename.20090505.txt filename.20090504.txt filename.20090503.txt filename.20090502.txt filename.20090501.txt My load date is 20090501 and run date... (5 Replies)
Discussion started by: RubinPat
5 Replies

8. UNIX for Dummies Questions & Answers

cmp 2 variables

Hi I have two variables contining a set of near identical lines, i'd like to list the lines that differ? Prefereably i'd like not to save the variables into a file first. i.e var1 tag:val1 tag:val2 tag:val3 var2 tag:val1 tag:val4 tag:val3 i'd like the result to print out... (2 Replies)
Discussion started by: nickrick
2 Replies

9. Shell Programming and Scripting

cmp, diff need options

Hi, I am using diff filename1 filename2, as these files are of huge size,I want to know the count(n) no. of different records to be displayed on the terminal. I do not want the contents of file i mean different lines to be displayed. Cheers Kunal. (0 Replies)
Discussion started by: niceboykunal123
0 Replies
Login or Register to Ask a Question