[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Linux, output redirection

Posted on 2014-01-10
3
Medium Priority
?
283 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

650 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