Solved

Linux, output redirection

Posted on 2014-01-10
3
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39771376
./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
ID: 39771384
Use 2>&1
0
 
LVL 68

Expert Comment

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

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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

749 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