[SGVLUG] Shell quoting
Rae Yip
rae.yip at gmail.com
Mon Apr 19 09:54:10 PDT 2010
>From the bash man page:
"Enclosing characters in single quotes preserves the literal value
of each character within the quotes. A single quote may not
occur between single quotes, even when preceded by a backslash."
It's only double quotes that parses backslash as an escape char.
Generally I would use a heredoc if I wanted to send a bunch of mostly
fixed input into another program:
tablename=Components
cat <<EOFEOF
ALTER TABLE $tablename where
column1 = "value";
EOFEOF | mysql -u user -p matt at somedb
-Rae.
On Mon, Apr 19, 2010 at 9:29 AM, Matt Campbell <dvdmatt at gmail.com> wrote:
> Wow. And I thought I knew my shell cold.
>
> Does anyone know the logic why this does not work?
>
>
>
> matt at scar:166% bash -c 'echo \'ALTER TABLE\' '
>
> Unmatched '.
>
>
>
> And how this is actually parsed?
>
>
>
> matt at scar:144% bash -c echo 'ALTER TABLE `Components`'
>
> (returns a blank line)
>
>
>
>
>
> Matt
>
>
More information about the SGVLUG
mailing list