Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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).

    -derby

    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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1064581]
Approved by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2016-12-07 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (130 votes). Check out past polls.