LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-31-2010, 07:29 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Rep: Reputation: 51
Redirecting or piping 'somecommand --help'.


kernel 2.6, slackware 12.0
mkisofs 2.01

Hi:
If I do 'ls --help|more' all's well. 'mkisofs --help' outputs its help screen, and I can use Shift+PgUp/PgDn to scroll through it. But I can neither pipe it to more or to less, nor redirect it to some file. more is simply ignored. Less, gets into less but only the last screenful is seen. Redirection, i.e. 'mkisofs --help>john.txt' produces an empty file (size= 0). And the same happens with some other commands, besides mkisofs. Is there a way around this? Thanks is advance.

Last edited by stf92; 10-31-2010 at 07:37 AM.
 
Old 10-31-2010, 08:07 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
The help text is being printed to stderr instead of stdout. You need to use I/O redirection in order to access it directly.

To redirect stderr to stdout in the shell:
Code:
mkisofs --help 2>&1 | less
To redirect stderr to a file:
Code:
mkisofs --help 2>filename
There's more on I/O redirection here:
http://tldp.org/LDP/abs/html/io-redirection.html
 
Old 10-31-2010, 02:56 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Original Poster
Rep: Reputation: 51
Thank you for your kind and useful reply. In the meantime, I remembered I had seen a command named script and, using it, I sent the help output to a file. But your solution is more economical. Above all, to know that the output was being sent to stderr was a great thing. Regards.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux piping vs Windows piping emanabela Linux - Newbie 1 05-10-2009 01:58 PM
piping | jezz Linux - General 2 05-04-2008 05:28 AM
Piping ls Kcghost Linux - General 9 03-05-2008 08:24 PM
piping and redirecting files shtek Linux - Newbie 4 01-15-2008 10:39 AM
Help with piping mijohnst Linux - General 7 10-21-2005 05:14 PM


All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration