Unix
Checking disk space
Submitted by pete on Mon, 2009-03-30 07:26Here is a quick and dirty diskspace script:
#!/bin/bash
ALERT=70
#ssh 10.61.37.176 df -H > /tmp/df.out
df -Hl > /tmp/df.out
cat /tmp/df.out | grep -vE 'Filesystem|tmpfs|cdrom' \
| awk '{ print $5 " " $1 " " $6 }' | \
while read output ;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $3 }' )
if [ $usep -ge $ALERT ]
then
printf "Running out of space on partition %s \t %g \t %s %s\n" \
$partition $usep $(hostname) $(date)
fi
done
Notice the hard coded ALERT level as well as the commented out ssh command.
It needs work, but should show you how little space one has on all mounted drives.
Shell scripts
Submitted by albert on Fri, 2008-10-10 18:13A good reference for Bash: http://www.math.ucdavis.edu/~zjohnson/doc/Adv-Bash-Scr-HOWTO/
How can one remember the syntax of the if command?
Getting $PATH line by line
Submitted by luke on Sat, 2008-07-12 13:16echo $PATH | tr ':' '\n' will list the $PATH nicely.
So will this:
echo $PATH | sed "s/:/\\
> /g"
That is hitting return and getting the ">" that is not typed in.
