Thomas Johnson
Thomas Johnson

Reputation: 11658

How can I prevent parallel from adding extra escaping to my command?

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?

Upvotes: 4

Views: 1713

Answers (1)

chepner
chepner

Reputation: 531075

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.

Upvotes: 4

Related Questions