简体   繁体   English

在bash脚本中重定向stdin和stdout

[英]Redirect stdin and stdout in bash script

I would like to create a bash script where it executes java command like: 我想创建一个bash脚本,在其中执行java命令,如:

java App < stdin > stdout 2> stderr

so I can run this script, pass files to stdin, stdout, stderr and it would execute it. 因此我可以运行该脚本,将文件传递给stdin,stdout,stderr,它将执行该脚本。

./script < file1 > file2 2> file3 

And it's gonna do: 它会做:

java App < file1 > file2 2> file3

How to redirect input and output? 如何重定向输入和输出?

java已经从Shell继承了其文件描述符,因此您无需在脚本内做任何特殊的事情

java App

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM