Solved

Redirecting just stdout through pipe in bash

Posted on 2006-07-12
3
1,527 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

860 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