I have following bash command

diff <(xzcat file1.xz) <(xzcat file2.xz)

and I need to execute it in dash. On my system (Debian Wheezy), dash is the default interpreter for cron (/bin/sh is a link to /bin/dash).

When I execute the command in dash, I get following error:

Syntax error: "(" unexpected

Yes, process substitution is a non-standard feature originated in ksh and only available in ksh, bash and zsh.

On systems that support /dev/fd/n (like Debian), you can do:

xzcat < file1.xz | { xzcat < file2.xz | diff /dev/fd/3 -; } 3<&0

Or you can always do:

bash -c 'diff <(xzcat file1.xz) <(xzcat file2.xz)'

If you need a specific shell when running something from a cron job wrap it in a script and call the script from the cron.


diff <(xzcat file1.xz) <(xzcat file2.xz)

Cron entry

*  *  *  *  * user-name  /path/to/above/script.bash

If you must use dash, this will work:

mkfifo file1
mkfifo file2
xzcat file1.xz >file1&
xzcat file2.xz >file2&
diff file1 file2
rm -f file1 file2 #remove the FIFOs
  • 1
    That's a can of worm though as you have to make sure only one instance is run at a time and that the fifos are not readable by anybody, and that they are properly created and destroyed... – Stéphane Chazelas Oct 2 '13 at 15:28
  • @StephaneChazelas Agreed. Thanks for pointing this out. – Joseph R. Oct 2 '13 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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