I was editing a shell script and I want to know how can use for to use all directories listed by a list or variables and then execute a command.
Example:
I have this directories:
/dirname1/app1
/dirname1/app2
/dirname2/app1
/dirname2/app2
The thing is each directory have 8 application directory, and I need to get the value of each one using du for usage of each one.
I have this example piece of code that I made, but I want to convert it more better than the actually have.
#!/bin/ksh
#files="/dev /etc"
inc=1
for f in /*;
do
vari=`du -ksh $f`
[ -d $f ]
echo "The value of each one is: ------ : $((inc++)): $vari"
done;
echo "Execution Done."
exit 0
I hope to be cleared with this,
$f
is a directory? If so your syntax is wrong; you don't have anif
statement anywhere. Do you haveapp1
throughapp8
in each ofdirname1
anddirname2
, and you want to list the summarized usage for eachappN
directory? – Wildcard Apr 25 '16 at 20:12Yes, I want the usage summary of each app from app1 to app8 in each directory. I put this piece of code just for example, Im trying to make the easy way to make it but, Im newbie learning shell scripting.
– vicdeveloper Apr 25 '16 at 20:18