Hi,
I have a file which has the following
/u12/data/oracle/abc.dbf
/u12/data/oracle/def.dbf
/u12/data/oracle/daf.dbf
/u12/data/oracledb/fgh.dbf
/u12/data/oracledb/fkh.dbf
/u12/data/oracledb/kdq.dbf
I want to do something like this
/u12/data/oracle
/u12/data/oracle
/u12/data/oracle
/u12/data/oracledb
/u12/data/oracledb
/u12/data/oracledb
I need to ignore the last word *.dbf
and use uniq command to find the mount point for checking space usage
df -m /u12/data/oracle
df -m /u12/data/oracledb
Thnx
Kaleem
yazu
2
while read line; do
dirname "$line"
done <INPUTFILE | sort -u | xargs df -m
Using awk:
$ awk ' /\/[^/]*.dbf$/ { sub("/[^/]*.dbf$","") ; A[$0]++ }
END {for(dir in A) print "df -m " dir }' infile
df -m /u12/data/oracle
df -m /u12/data/oracledb
If your happy with the output you can use system() to run the df commands instead of print.
$ nawk -F/ '{$NF= ""; print}' infile | sed 's, ,/,g;s,^,df -m ,g' | sh
ctsgnb
5
sed -e 's!/[^/]*$!!' infile | uniq | xargs df -m
awk -F/ 'BEGIN{OFS="/"}{$NF="";print}' test | sort -u | xargs df -m
danmero
7
awk -F/ '{NF--;a[$0]}END{for(i in a) print i}' OFS=/ file | xargs df -m
ygemici
8
for i in $(sed 's/^ //g;s/\(.*\)\/.*$/\1/' infile|sed '$!N;/^\(.*\)\n\1$/!P;D')
> do df -m $i ; done