Question

I'm trying to get parallel to run a command and pass a date in quotes. But it's adding an extra backslash before the spaces in the parameter:

$ echo "2014-05-01 01:00" | parallel --dry-run foo \"{}\"
foo "2014-05-01\ 01:00"

How can I get parallel to not add that extra \ after 2014-05-01?

Was it helpful?

Solution

Drop the escaped quotes from your command:

echo "2014-05-01 01:00" | parallel --dry-run foo "{}"

When parallel replaces {} with the line of input, it knows that the line should be a single argument, so it will escape the space for you. Your previous command simply added literal quote characters to the beginning and end of the argument.

Note that from the shell's perspective, the following are identical

foo "2014-05-01 01:00"
foo 2014-05-01\ 01:00

so if you are trying to force the output to look like the first one, don't: it's a cosmetic difference only.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top