LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2009, 08:30 AM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Rep: Reputation: 110Reputation: 110
command outputs more than I want


Sometimes I like to check my partitions and see how many mounts I have until fsck is forced at boot (which takes a loooong time):

Code:
dumpe2fs /dev/sda5 | grep -i 'mount count'
So I made a script:

Code:
echo usr
dumpe2fs /dev/sda3 | grep -i 'mount count'
echo

echo home
dumpe2fs /dev/sda5 | grep -i 'mount count'
echo

echo backup
dumpe2fs /dev/sdb1 | grep -i 'mount count'
echo
And this is the output:

Code:
usr
dumpe2fs 1.40.8 (13-Mar-2008)
Mount count:              1
Maximum mount count:      20

home
dumpe2fs 1.40.8 (13-Mar-2008)
Mount count:              18
Maximum mount count:      20

backup
dumpe2fs 1.40.8 (13-Mar-2008)
Mount count:              18
Maximum mount count:      20
Why is that version and date string included in the output? It does not match my grep expression.
 
Old 09-09-2009, 08:38 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
It prints the Version information to the standard error. Since only the standard output is sent through the pipe, the standard error is sent to the terminal, unless you redirect it to /dev/null or together with standard output through the pipe. Also note that if you use the option -h you will print out the header information only, reducing the time of execution:
Code:
dumpe2fs -h /dev/sda3 2>/dev/null | grep -i 'mount count'   # or
dumpe2fs -h /dev/sda3 2>&1 | grep -i 'mount count'
 
Old 09-09-2009, 09:39 AM   #3
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Excellent! Thanks!
 
  


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
The DU command and DF command, Different Outputs??? jamie2teach Linux - Newbie 3 07-10-2009 07:25 AM
Sox recording command outputs blank files anid.iitk Linux - Newbie 2 05-29-2006 01:09 AM
Specify where nohup outputs to? chibi Linux - General 1 01-31-2006 02:15 AM
should i worry about these outputs? wza Linux - General 3 01-10-2004 12:18 AM
Different nmap outputs, one ip iceman47 Linux - Security 10 05-12-2003 04:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:26 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