Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to download multiple files and save them to the md5 sum of its name:

cat list | parallel -j4 "md5=$(wget -O - {} | tee tmpfile_{#} | md5sum | cut -d ' ' -f 1); mv tmpfile_{#} $md5"

but the problem is that bash seems to execute the wget stuff before execution of parallel replaces {}... so wget wants to download from http://{}

so how can parallel replace its variables before the execution of the subcommand?

share|improve this question

1 Answer 1

some trial and error later:

cat list | parallel -j4 'md5=$(wget -O - {} | tee tmpfile_{#} | md5sum); mv tmpfile_{#} ${md5%% *}'

just replace " with ' does not allow bash to replace something first

share|improve this answer
    
You might also want to read about Word Splitting. –  Rany Albeg Wein Apr 25 '13 at 0:42
    
Following the manual or a guide is usually better than doing trial-and-error –  ignis Apr 27 '13 at 17:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.