Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

sh: -c: line 0: syntax error near unexpected token `('

by ilans11il (Initiate)
on Nov 27, 2013 at 08:54 UTC ( #1064581=perlquestion: print w/replies, xml ) Need Help??
ilans11il has asked for the wisdom of the Perl Monks concerning the following question:

Hi , Could you please advise , What is wrong with my command:
$RT_DiffFiles= `comm -23 <(sort $RT_64OG_FilesPath) <(sort $RT_64_File +sPath)`;
the error:
sh: -c: line 0: syntax error near unexpected token `(' sh: -c: line 0: `comm -23 <(sort ./TmpData/RT_64OG_Files) <(sort ./Tmp +Data/RT_64_Files)'
the print of the command:
comm -23 <(sort ./TmpData/RT_64OG_Files) <(sort ./TmpData/RT_64_Files)
from linux the command is working with no problem... thanks in advanced

Replies are listed 'Best First'.
Re: sh: -c: line 0: syntax error near unexpected token `('
by derby (Abbot) on Nov 27, 2013 at 11:08 UTC

    Looks like sh on your system is not bash (or any shell that supports the process substitution syntax).


    Update: You could always force bash:

    $RT_DiffFiles= `bash -c \"comm -23 <(sort $RT_64OG_FilesPath) <(sort $ +RT_64_FilesPath)\"`;
    but I'd look to see if Text::Diff accomplishes what you're after first.

Re: sh: -c: line 0: syntax error near unexpected token `('
by oiskuu (Hermit) on Nov 27, 2013 at 17:48 UTC
    Compare FOO=... to $FOO=.... First one assigns to a variable, the latter will expand variable, =, ... parts, then attempt to execute the result.

    In other words, be mindful of where you put the $.

      RT_DiffFiles=`comm -23 <(sort $RT_64OG_FilesPath) <(sort $RT_64_FilesPath)`;
      echo "$RT_DiffFiles";

    Are you trying to rewrite this as perl code?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1064581]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2016-10-20 22:30 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (283 votes). Check out past polls.