LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 06:29 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
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 06:37 AM.
 
Old 10-31-2010, 07:07 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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, 01:56 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
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



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 12:58 PM
piping | jezz Linux - General 2 05-04-2008 04:28 AM
Piping ls Kcghost Linux - General 9 03-05-2008 07:24 PM
piping and redirecting files shtek Linux - Newbie 4 01-15-2008 09:39 AM
Help with piping mijohnst Linux - General 7 10-21-2005 04:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:53 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
Open Source Consulting | Domain Registration