I want variable substitution in part of the command.
So just escape those dollars which you want to pass as literals.
#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 1; my $boot_device = '/dev/md126p1'; my $cmd = qq#blkid $boot_device | awk '{ print \$2 }' | sed 's/"//g'#; my $shouldbe = q#blkid /dev/md126p1 | awk '{ print $2 }' | sed 's/"//g +'#; is ($cmd, $shouldbe);
And never pipe awk to sed - that would be pointless.
In reply to Re^3: system call (backticks) with pipes
by hippo
in thread system call (backticks) with pipes
by papai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |