에서 리디렉션을 사용할 때이 ProcessBuilder를 사용하여이 명령을 실행하려는 ProcessBuilder를 사용하는 방법 : 다음 나는 시도리눅스
sort -m -u -T /dir -o output <(zcat big-zipped-file1.gz | sort -u) <(zcat big-zipped-file2.gz | sort -u) <(zcat big-zipped-file3.gz | sort -u)
을 :이 같은 args
을 사용하고
// This doesn't recognise the redirection.
String[] args = new String[] {"sort", "-m", "-u", "-T", "/dir", "-o", "output", "<(zcat big-zipped-file1.gz | sort -u)", "<(zcat big-zipped-file2.gz | sort -u)", "<(zcat big-zipped-file3.gz | sort -u)"};
// 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 | sort -u) <(zcat big-zipped-file2.gz | sort -u) <(zcat big-zipped-file3.gz | sort -u)\""};
: processBuilder.command(args);
내 질문이 업데이트되었습니다. 여러 zcat 명령의 출력을 정렬로 리디렉션하고 싶습니다. –
ProcessBuilder가 셸이 아닙니다. 쉘을 명시 적으로 호출하거나 리디렉션을 직접 수행하십시오. – jtahlborn
이것은 중복되지 않습니다. 여기의 문제는 다릅니다. 두 번째 시도에서 명시 적으로 쉘을 호출했습니다. –