[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

Linux, output redirection

I have a program I run that calls a java jar which produces both output and error stacks

./s.sh

Open in new window


The error stack (and output combined) are too much for my screen and I want to redirect both output and error info to a single file, something like

./s.sh > a.out

Open in new window


However, not all data is redirected there, and I don't quite know how to redirect botht he error and output to the same file

Could someone plese post and example of how to do this ?

Thanks
0
Los Angeles1
Asked:
Los Angeles1
  • 2
1 Solution
 
woolmilkporcCommented:
./s.sh > a.out 2>&1

"1" (the default) is the is the file descriptor of stdout and "2" is the one of stderr.

2>&1 means "redirect stderr to where stdout is redirected right now", so a.out will contain a mix of stdout and stderr.
0
 
David CarrCommented:
Use 2>&1
0
 
woolmilkporcCommented:
You can also separate stdout and stderr (redirect to two distinct files), like this:

./s.sh >a.out 2>e.out
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now