Embedded quotes in shell command. HELP!!
Date: 13 Sep 2005 07:40:20 -0700
I'm having a problem where a Perl script needs to launch a command in
the following format (which doesn't work now):
ssh appserv1 -l appadmin 'find /app2/files/*.txt-* -mtime -1 | grep -v
'Z$' | cut -d . -f 1'
As you can see, what this command does is logs on to server appserv1,
pulls *.txt* files from directory /app2/files/ that are not older than
one day, filters the results with grep command so that entries for
files ending with letter Z are not retrieved, and uses cut command to
remove file extensions.
My problem is with nested single-quotes, as the grep command requires
the pattern to be single-quoted. But in this case the entire command
following ssh appserv1 -l appadmin must be single quoted as well (or am
I missing something?).
Is there a way to escape the inner single quotes in this command, cuz
otherwise I'll have to write a separate Perl routine for filtering the
entries ending with letter Z, in which case I can remove the grep
command from the statement.
Thanks for your help,