Solved

Linux, output redirection

Posted on 2014-01-10
3
276 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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
linux apache localhost dev laptop 5 48
Issue with SFTP on non-root account using Guacamole  / GUAC 2 61
Hacked File Timestamps 4 49
linux redhat 7.2 10 30
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…

914 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

14 Experts available now in Live!

Get 1:1 Help Now