Cutting disk space output

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Cutting disk space output
# 8  
Old 08-31-2016
Assuming that line 2 is always / the following is more efficient
Code:
df -h / | awk 'NR>1 {print $8}'

For comparison against thresholds the {print $8+0} returns the pure number.
This User Gave Thanks to MadeInGermany For This Post:
# 9  
Old 08-31-2016
If you are using bash or something similar you could try something like:-
(OSX 10.7.5, defaul bash terminal.)
Code:
Last login: Wed Aug 31 08:52:38 on ttys000
AMIGA:barrywalker~> root_percent_used=( $( df -h ) )
AMIGA:barrywalker~> echo "${root_percent_used[11]}"
4%
AMIGA:barrywalker~> _

Note that the array field [11] might not be the same for your platform so adjust to suit.
Just an idea...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Gawk --- produce the output in pattern space instead of END space

hi, I'm trying to calculate IP addresses and their respective calls to our apache Server. The standard format of the input is HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST... (2 Replies)
Discussion started by: busyboy
2 Replies

2. Shell Programming and Scripting

Disk Space Script to direct output

Hi, I am working on Sun Solaris 5.10 and want to direct the output from a disk space check script to an output file; #!/bin/bash CURRENT=$(df -k /log/logs | grep /log/logs | awk '{ print $5}' | sed 's/%//g') THRESHOLD=30 if ; then echo "Remaining free space is low" > output.txt else... (10 Replies)
Discussion started by: SSKAAB
10 Replies

3. Shell Programming and Scripting

Disk Space Output

I am very new to unix and Linux, So I have a question about LINUX and AIX. What LINUX and AIX commands can be used to get the following output: 071912 GB blocks Free %Iused Mounted on 071912 5.00 4.64 8% / 071912 15.00 9.44 38% /usr 071912 6.00 2.56 58% /var 071912 15.00 12.88 15% /tmp... (1 Reply)
Discussion started by: najeemsarwat
1 Replies

4. Emergency UNIX and Linux Support

Disk space script output in color

I'm connecting to 15 servers in using ssh and storing disk space details of each server in a text file Finally , I'm emailing that text file at the particular id using mail -x . The report looks something like this. Filesystem size used avail capacity Mounted on /proc ... (30 Replies)
Discussion started by: ajaypatil_am
30 Replies

5. Solaris

Disk Space

I know there are other threads but they have not helped. My server is running low on disk space and I haven't been able to re-allocate. I think my solaris machine is missing tools or the way it was originally setup, may not have the right pathing. $ df -k Filesystem kbytes used... (5 Replies)
Discussion started by: lnxjenn
5 Replies

6. Shell Programming and Scripting

Cutting strings from output of command

Hi, I am new to scripting and need help in cutting strings from output of a command. For exapmle in am getting the following as the out out from the command i run: Out Condition: Askajdsdfa | date: 1204 | oper: + I need to get the output as Askajdsdfa and 1204. Thanks (3 Replies)
Discussion started by: hraj1984
3 Replies

7. Shell Programming and Scripting

combining cat output and cutting rows

I have a file that contain the following. -D HTTPD_ROOT="/usr/local/apache" -D SERVER_CONFIG_FILE="conf/httpd.conf" I want a shell script, so that after cat filename and apply the shell script I should get the output as follows. /usr/local/apache/conf/httpd.conf ie cat filename |... (7 Replies)
Discussion started by: anilcliff
7 Replies

8. Shell Programming and Scripting

Cutting Part of Output

Hello all I'm using bourne shell and need to figure out how to cut out a specific portion of some output. For example, my output from my command is: 12.12.52.125.in-addr.arpa name = hostname.domain.main.gov I need to get just the "hostname.domain.main.gov" part. What I'm trying... (9 Replies)
Discussion started by: lee.n.doan
9 Replies

9. UNIX for Dummies Questions & Answers

available disk space on disk device???

Hello, Can someone please tell me which command to use to determine the available disk space on a given disk device? I have to write a shell script that compresses files and stores them in a specific location but I am not sure how "conservative" I should be? Thanks in advance! Al. (4 Replies)
Discussion started by: alan
4 Replies
Login or Register to Ask a Question