Guilhem Faure
Guilhem Faure

Reputation: 53

Why some GNU parallel input include quotes?

Gnu parallel input (e.g. from a pipe) automatically single quotes input that contains space or symbols like / and : Is there a reason for that? How can I print the input as it is without any quote?

I tried with various parallel options like -q or with different type of quotes to embed the input in the parallel command, however, it always shows up with single quotes when the input contains space of / symbols.

Here are the command lines I tried:

awk '{print "ftp://"$1}' assembly2contig.lst | parallel --dry-run wget '{}'

Output will be

wget 'ftp://mypath'
awk '{print $1}' assembly2contig.lst | parallel --dry-run wget 'ftp://{}'

This command works but I need to build my path within parallel which is not very convenient for my cases, e.g. when my input file already contains paths.

I would like to obtain

wget ftp://mypath

using ftp://mypath as parallel input coming from the pipe (e.g. awk)

Upvotes: 4

Views: 1147

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207808

If assembly2contig.lst looks like this:

hp.com/something abcde 1234
ibm.com/other fred 3390
bbc.co.uk/film1 bill 999

You could avoid awk altogether and use:

parallel --colsep ' ' --dry-run -a assembly2contig.lst wget ftp://{1}

Or if the input is a pipe:

cat assembly2contig.lst | parallel --colsep ' ' --dry-run wget ftp://{1}

Sample Output

wget ftp://hp.com/something
wget ftp://ibm.com/other
wget ftp://bbc.co.uk/film1

Upvotes: 0

Ole Tange
Ole Tange

Reputation: 33740

The reason for the quoting is to avoid the default behaviour in xargs:

echo 'two  spaces  lost' | xargs echo
echo 'two  spaces  kept' | parallel echo

To avoid this you can use eval:

echo 'two  spaces  lost' | parallel eval echo

Upvotes: 1

Related Questions