In Quoting constructs§

See primary documentation in context for Shell quoting with interpolation: qqx

If one wishes to use the content of a Raku variable within an external command, then the qqx shell quoting construct should be used:

my $world = "there";
say qqx{echo "hello $world"};  # OUTPUT: «hello there␀»

Again, the output of the external command can be kept in a variable:

my $word = "cool";
my $option = "-i";
my $file = "/usr/share/dict/words";
my $output = qqx{grep $option $word $file};
# runs the command: grep -i cool /usr/share/dict/words
say $output;      # OUTPUT: «Cooley␀Cooley's␀Coolidge␀Coolidge's␀cool␀...»

Be aware of the content of the Raku variable used within an external command; malicious content can be used to execute arbitrary code. See qqx traps

See also run and Proc::Async for better ways to execute external commands.