dimanche 17 juillet 2016

How to use ProcessBuilder when using redirection in Linux

I want to run this command using ProcessBuilder:

sort -m -u -T /dir -o output <(zcat big-zipped-file1.gz) <(zcat big-zipped-file2.gz) <(zcat big-zipped-file3.gz) 

I have tried the following:

// This doesn't recognise the redirection.
String[] args = new String[] {"sort", "-m", "-u", "-T", "/dir", "-o", "output", "<(zcat big-zipped-file1.gz)", "<(zcat big-zipped-file2.gz)", "<(zcat big-zipped-file3.gz)"};

// This gives:
// /bin/sh: -c: line 0: syntax error near unexpected token `('
String[] args = new String[] {"/bin/sh", "-c", ""sort -m -u -T /dir -o output <(zcat big-zipped-file1.gz) <(zcat big-zipped-file2.gz) <(zcat big-zipped-file3.gz)""};

I am using args like this: processBuilder.command(args);

Aucun commentaire:

Enregistrer un commentaire