For my edification, I'd like to find out how to escape quotes within the system
command in the following perl oneliner:
$ ls -p | grep -v / | perl -lane 'system("echo \"$_\"");'
without using the \"
escape sequence, in the manner shown here: https://stackoverflow.com/a/1250279/3367247
(Obviously this command does nothing useful; it just prints filenames that have spaces in them. But it serves to explain my problem succintly.)
I tried the following (pardon the images, but I have found highlighting easiest to decipher the quoting):
Code: $ ls -p | grep -v / | perl -lane 'system("echo ''"''$_''"''");'
Code: $ ls -p | grep -v / | perl -lane 'system('"'"'echo "$_"'"'"');'
Neither of these work. Is there a way to accomplish this in the manner of the linked answer?
EDIT: I need double-quotes around the $_
in the echo command because the string in $_
contains parentheses, not because it contains spaces, as I originally thought.