Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 112
  • Last Modified:

UNiX Script filesystem space usage

I am working on a simple script and I cannot get the command to execute. I am certain I am missing a quote somewhere but cannot get the command to run. The script I have is below. The command by itself executes. When attempting to run in a script it will not

#! /bin/sh

OUTPUT="$(df | egrep "([89][0-9]|100)%")"
Echo "$(OUTPUT)"
0
Frog_1337
Asked:
Frog_1337
  • 8
  • 5
  • 4
  • +1
8 Solutions
 
Gerwin Jansen, EE MVETopic Advisor Commented:
output=$(df | egrep "([89][0-9]|100)%")
echo ${output}
0
 
Frog_1337Author Commented:
This is not working. The output is blank where as the command ran by itself gives the filesystems over the percentage
0
 
omarfaridCommented:
try this

OUTPUT=`df | egrep "[89][0-9]|100)%"`
Echo $OUTPUT
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
omarfaridCommented:
correction

OUTPUT=`df | egrep "[89][0-9]|100%"`
Echo $OUTPUT
0
 
Frog_1337Author Commented:
No its only echoing the command not the output
0
 
omarfaridCommented:
note to use ` not ' in the first line
0
 
Frog_1337Author Commented:
Still not working. I just need this command to echo an output

df | egrep "([89][0-9]|100)%"
0
 
omarfaridCommented:
please run below command then post output:

df | egrep "[89][0-9]|100%"
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
If you have a working command just add echo like this:

echo $(your working command)
0
 
Frog_1337Author Commented:
(258)==> df | egrep "([89][0-9]|100)%"
/dev/vg00/sysadmlv 2097152 1669080  401479   81% /sysadm
wins04:root:[/]
(259)==>
0
 
Frog_1337Author Commented:
When I try the echo$(command) I still do not get output
0
 
arnoldCommented:
Your double quotes in the assignment might be the issue,
Opening quotes might have been closed by the quotes for the egrep.
Either escape the inner quotes, remove the outer or try the following.

output=$(df| egrep '([89][0-9]|100)\%' )
echo $output
0
 
Frog_1337Author Commented:
Still no output. Im thinking I may have to take a different route or something
0
 
arnoldCommented:
look at the output of df
Try using df -k instead.
df |egrep '\%'
Do you have all but the first rows displayed?
0
 
Frog_1337Author Commented:
This is hpux 11.1 so no -k function.
df |egrep '\%' Gives full df output when ran normally
0
 
omarfaridCommented:
your out put is correct, as you posted:

(258)==> df | egrep "([89][0-9]|100)%"
/dev/vg00/sysadmlv 2097152 1669080  401479   81% /sysadm

now try this:

OUTPUT=`df | egrep "([89][0-9]|100)%"`
echo $OUTOUT
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
>> When I try the echo$(command) I still do not get output
Is does for me, you must be doing something wrong. Can you post your commands + output (copy from screen), maybe you're echoing Output and not output - casing matters as you may know.

$ df | egrep "([89][0-9]|100)%"
devfs                                    353       353         0   100%       611         0  100%   /dev
map -hosts                                 0         0         0   100%         0         0  100%   /net
map auto_home                              0         0         0   100%         0         0  100%   /home
$ output=$(df | egrep "([89][0-9]|100)%")
$ echo ${output}
devfs 353 353 0 100% 611 0 100% /dev map -hosts 0 0 0 100% 0 0 100% /net map auto_home 0 0 0 100% 0 0 100% /home
$ echo $(df | egrep "([89][0-9]|100)%")
devfs 353 353 0 100% 611 0 100% /dev map -hosts 0 0 0 100% 0 0 100% /net map auto_home 0 0 0 100% 0 0 100% /home
$ 

Open in new window

0
 
Frog_1337Author Commented:
It was the case sensitive issue thank you
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
You're welcome ;)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 5
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now