Solved

Linux, output redirection

Posted on 2014-01-10
3
275 Views
Last Modified: 2014-01-10
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
Comment
Question by:Los Angeles1
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
Comment Utility
./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
 
LVL 9

Expert Comment

by:David Carr
Comment Utility
Use 2>&1
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
You can also separate stdout and stderr (redirect to two distinct files), like this:

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now