Thanks Parvin.
It okay, but the output like this:
count 1
Media,[1],0 GB
count 2
Document,[2],1.99303e-07 GB
Available space ; 0
Do you have other way like this
count 1 <-- need to remove
Media,[1],0 GB <-- remove [1]
count 2 <-- need to remove
Document,[2],1.99303e-07 GB <--remove [2]
Available space ; 0
For example:
Media,0 GB
Document,1.99303e-07 GB
Others,0 GB
Available space ; 0
and one more is available space:
[root@CentOS user]# df -k /home/user
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
17093992 5337976 10887664 33% /
[root@CentOS user]#
[root@CentOS user]# df -h /home/user
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
17G 5.1G 11G 33% /
[root@CentOS user]#
After run scripts the output show 0 but from df -h and df -k still available
Sorry I'm totally lost!
---------- Post updated 03-19-11 at 04:08 AM ---------- Previous update was 03-18-11 at 05:44 AM ----------
Hi all,
This is updated scripts but still need feedback from expect.
Run scripts ./myScripts.sh > list.txt
This is ./myScripts.sh:
#!/bin/sh
ls -lR | egrep ^- > test.txt
Type[1]='"\.avi\$|\.mov\$|\.mp3\$"'
LABEL[1]=Media
Type[2]='"\.doc\$|\.xls\$"'
LABEL[2]=Document
Type[3]='"\.png\$"'
LABEL[3]=Image
for count in 1 2 3;
do
echo count $count
echo ${LABEL[$count]},`eval egrep ${Type[$count]} test.txt |awk -v l="$LABEL[$count]" '{ SUM += $5} END { SUM=SUM/1073741824 ; print l","SUM" GB"}'`
done
# Available space
df -P /home/sheikh | awk 'NR==2{print "Available,0,",$4/1048576 " GB"}'
# For remove count [num]
sed -i~ -e 's/count.*$//' list.txt
# For remove column no. 2
cat list.txt | awk 'BEGIN{FS=",";OFS=","}{$2=$6="";gsub(FS "+",FS)}1' > output.txt
list.txt
count 1
Media,[1],0 GB
count 2
Document,[2],0.000241002 GB
count 3
Image,[3],0.000567848 GB
Available,0, 10.3802 <-- Put dummie 0 for delete column no 2
Output:
[root@CentOS user]# cat output.txt
, <-- Problem no.1
Media,0.0132836 GB,
, <-- Problem no.2
Document,0.000241002 GB,
, <-- Problem no.3
Image,0.000567848 GB,
Available, 10.3802 GB, <-- Problem no. 4
[root@CentOS sheikh]#
Problem no.1 to problem no.3 is space row. I need to do without space. Related to this scripts:
# For remove count [num]
sed -i~ -e 's/count.*$//' list.txt
Reason - Want to remove "count 1 until count 3" It's is the right scripts?
Wanted output:
Media,0.0132836 GB,
Document,0.000241002 GB,
Image,0.000567848 GB,
Available, 10.3802 GB,
Problem no.4, put 0 at column no.2
Available,0, 10.3802 <-- Put dummie 0 for delete column no 2
If without value in column no 2, then figure 10.3802 will be deleted. Any command without to put 0.
Please help me..