I noticed that when I use backticks in perl the commands are executed using sh, not bash, giving me some problems.
How can I change that behavior so perl will use bash?
PS. The command that I'm trying to run is:
paste filename <(cut -d \" \" -f 2 filename2 | grep -v mean) >> filename3
Create a perl subroutine:
And use it like below:
Or use perl here-doc for multi-line commands:
To deal with running bash and nested quotes, this article provides the best solution: How can I use bash syntax in Perl's system()?
Try
I am fairly sure the argument of -c is interpreted the way bash interprets its command line. The trick is to protect it from
sh
- that's what quotes are for.I thought
perl
would honor the$SHELL
variable, but then it occurred to me that its behavior might actually depend on your system'sexec
implementation. In mine, it seems thatexec
You can always do
qw/bash your-command/
, no?This example works for me:
The "system shell" is not generally mutable. See perldoc -f exec:
If you really need bash to perform a particular task, consider calling it explicitly:
or even:
You could also put your bash commands into a .sh file and invoke that directly: