Running External Programs in Julia with special characters ">"

Viewed 144

I want run an external program in Julia which contains the special characters ">"

gunzip -c file.nc.gz > file.nc

But I get this error:

ERROR: LoadError: LoadError: parsing command `gunzip -c $filein /> $fileout`:
       special characters "#{}()[]<>|&*?~;" must be quoted in commands

I can I solve this problem? Thanks

1 Answers

Use pipeline instead of using shell syntax (>) for stream redirection.

Example:

shell> ls
file.txt.gz

julia> p = pipeline(`gunzip -c file.txt.gz`; stdout="file.txt");

julia> run(p);

shell> ls
file.txt  file.txt.gz

shell> cat file.txt
hello, world

Alternatively you can invoke a shell that understand what > means, for example bash:

run(`/bin/bash -c "gunzip -c file.txt.gz > file.txt"`)
Related