I have a script that shows me the disk SPace used by different dir under my home dir:
#!/bin/ksh
cd /ednpdtu3/u01/pipe
p1=`df -g | tail -1 | tr -s " " | cut -d " " -f2`
echo "Total Disk Space of Home Dir is $p1 GB"
p2=`df -g | tail -1 | tr -s " " | cut -d " " -f3`
echo "Total Disk Space Free in Home Dir is $p2 GB"
count=`ls -ltr | grep ^d | wc -l`
echo "$count Dir found in HOME DIR"
a1=1
while [ $a1 -le $count ]
do
b=`ls -ltr | grep ^d | head -$a1 | tail -1 | tr -s " " | cut -d " " -f9`
#echo $b
a1=`expr $a1 + 1`
a2=`du -sk $b`
echo "$a2"
done
------------------------------------------------------------------------
Output i m getting:
28 ssh
89508 Outgoing
6393868 Incoming
4 Mail
----------------------------------------------------------
But i want to get only numeric value i.e. whenever it encounter space , it should remove spaces and watever is after spaces so that i can get onl;y numeric part. My o/p should be like below
28
89508
6393868
4
--------------------------------------------------------------
I know we can do it by SED and we have to implement this in a2=`du -sk $b` . I tried some commands with sed
,but not successfull
a2=`du -sk $b | `sed 's/ //g'-----> not working
I m pretty much sure we have to implement the logic in that part of the script i.e. a2=`du -sk $b` and using SED but not getting the correct way to use SED
Plz help me in this