Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by ilans11il (Initiate)
on Nov 27, 2013 at 08:54 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1064581]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-18 03:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found