LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-01-2015, 03:43 PM   #1
linux_nerd
LQ Newbie
 
Registered: Jun 2015
Posts: 26

Rep: Reputation: Disabled
Bash shell script that will count the output of df -h.


Hello all, I am working on a script but I am having a problem figuring out how to accomplish my task. I am stuck at the if statement, here is what I am doing. I want to be notified if the count is less than 6. I know the "$?" is wrong but as it is looking at the exit code. I dont know what I should put there. Any help would be great thanks.
Code:
/bin/df -h
if [ $? -lt 6]; then 
 "send email."
elif "echo something"
fi

Last edited by linux_nerd; 10-01-2015 at 03:45 PM.
 
Old 10-01-2015, 03:57 PM   #2
fogpipe
Member
 
Registered: Mar 2011
Distribution: Slackware 64 -current,
Posts: 550

Rep: Reputation: 196Reputation: 196
if you are just trying to count the number of lines in the output of df -h this works for me:
Code:
#!/bin/bash
value=$(/bin/df -h|wc -l)
if [ $value -lt 6 ]  
then  
        echo "something."  
fi
 
Old 10-01-2015, 04:43 PM   #3
linux_nerd
LQ Newbie
 
Registered: Jun 2015
Posts: 26

Original Poster
Rep: Reputation: Disabled
Perfecto
 
  


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
Shell script for time count sagar666 Linux - Server 4 04-21-2015 10:51 AM
Creating array from command output (bash shell script) Rizla Programming 5 01-26-2011 11:47 PM
Row count Shell Script zaeem Linux - Newbie 4 10-08-2010 08:35 PM
Help on my Linux Homework ! bash shell script / input-output data etc Bebelindo Programming 2 03-03-2009 01:51 PM
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 04:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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