Apologies if this is a basic question - I'm stuck trying to solve a larger problem, and it's come down to how a shell script is invoked - directly (
shellScript.sh
) or using sh shellScript.sh
.
Here's a model for the problem:
When I execute on bash:
cat <(echo 'Hello')
I see the output
Hello
But when I use:
sh -c "cat <(echo 'Hello')"
I see errors:
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `cat <(echo 'Hello')'
I've tried escaping the <
, (
and )
in various combinations, but I don't see the output anywhere. What am I missing here?
My actual problem is that I'm passing a <()
as an input argument to a python script within a shell script, and while it works fine when I invoke the shell script using just the name, if I use sh
to invoke it, I get errors similar to what I've shown above.
Thank you!
Asked by Ram RS
(111 rep)
May 9, 2017, 08:16 PM
Last activity: Jul 30, 2025, 06:24 AM
Last activity: Jul 30, 2025, 06:24 AM