Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将标准输入从 shell 脚本重定向到 shell 脚本中的命令?我正在尝试将标准输入传递给 java System.in 流。
我想换
find . -type f | $JAVA_HOME/bin/java com.domain.BatchProcess
和
find . -type f | ./batch.sh
如果您在脚本中执行命令,它将替换 shell 并继承它的文件描述符,包括 stdin、stdout 和 stderr。
如果命令:
$JAVA_HOME/bin/java com.domain.BatchProcess
期待来自标准输入的输入,然后将其放入脚本并运行您的第二个命令将起作用。
它会自动完成。