Solved

Redirecting just stdout through pipe in bash

Posted on 2006-07-12
3
1,526 Views
Last Modified: 2008-01-09
With a program I am using when I run this command:

          mycommand | grep hello

I get:

          Running...
         
          Done!
          Well hello there, how are you doing?

But when I run:

          mycommand|grep hello 1> hello.txt

I see:

          Running...
         
          Done!

And then when I cat "hello.txt" I get:

          Well hello there, how are you doing?

...which is what I want to get, but through a pipe (without having to cat the file afterwards).

How can I do this (just get the stdout, but through the pipe instead of on redirection)?  I've seen this in multiple programs.  Also, what category does the "Running..." and "Done!" fit under if not stdout?
0
Comment
Question by:Autogard
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
pjedmond earned 500 total points
ID: 17092775
Running..." and "Done" come under the stderr output. stderr(2) is also used for information that is not 'true output of the program concerned.

What you possibly require is:

mycommand 2>/dev/null | more

(   (()
(`-' _\
 ''  ''



0
 
LVL 22

Expert Comment

by:pjedmond
ID: 17092787
http://www.tldp.org/LDP/abs/html/io-redirection.html

gives a much fully description of what can be done:

(   (()
(`-' _\
 ''  ''

0
 
LVL 8

Author Comment

by:Autogard
ID: 17092849
Ahah! Exactly. Thanks! I'm using "mycommand 2>/dev/null | grep hello" and it works perfectly!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

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é.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.

776 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