command line to show total size of files

  • mo_mughrabi
  • Student
  • Student
  • User avatar
  • Posts: 73

Post 3+ Months Ago

hello,

i been trying to issue a command where i can see the total size of files. but also i want to show it in GB. when i do
Code: [ Select ]
ls -ltr PP*P


there is around 200 files i have here, with different sizes is there a way to get total size of all in GB?

p.s am on Unix Solaris

regards,
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • vijayan
  • Beginner
  • Beginner
  • vijayan
  • Posts: 52
  • Loc: india

Post 3+ Months Ago

Hello mo_mughrabi,

I saw your post.
I not sure taht this is in Unix Solaris the command is
du -h (filename or directory name)
You try it .
  • mo_mughrabi
  • Student
  • Student
  • User avatar
  • Posts: 73

Post 3+ Months Ago

du -h works only on linux env though it was executing under solaris but resulting different. went through the man pages there is no such for showing specific size.

I think with solaris the only way to do it is, look the size and calculate the size then put it into some sort of formula to result the final size in GB.

hmm, any ideas?
  • roca
  • Newbie
  • Newbie
  • roca
  • Posts: 5

Post 3+ Months Ago

Hello:

Command "du -s -k" will print a single number of kilobytes that you are using in the current directory.

perhaps this help you....

regards, roca.
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

have you tried df ?
  • learner2008
  • Born
  • Born
  • learner2008
  • Posts: 4

Post 3+ Months Ago

Since the “du” command will total up the disk usage in a folder and its sub folders, and if our requirement is to get total size of folder in each sub, sub-sub, etc folder, therefore, the du will give a wrong total for the mother folder, in this case, a loop is use to total up the size in each folder without summing up its sub-folders.

Meaning /home/user1/ may contain
/home/user1/file1 100KB
/home/user1/temp/file21 50KB
/home/user1/today/file31 30KB

This should be the output
/home/user1 100KB not 180KB
/home/user1/temp/ 50KB
/home/user1/today/ 30KB

for xmother_folder in `cat $list_of_mother_folder.txt`
do
for sub_folders in `ls -laR ${xmother_folder} | grep ":$" | sed "s/://g""
do

f_size_used=0
for xone_file_size in `ls -l ${sub_folders} | grep "^-" | awk '{print $4}`
do
f_size_used=`expr ${f_size_used} + ${xone_file_size}`
done
echo ${sub_folders} -- ${f_size_used}

done
done
  • learner2008
  • Born
  • Born
  • learner2008
  • Posts: 4

Post 3+ Months Ago

Dear All, I also got a question need help.
If I have a WINXP platform conmputer now connected to 100 UNIX servers, (meaning I can ping and telnet and ftp them) with the listA of IPs, loginID and password.

I have a script which I do not want to ftp to these 100 servers 1 at a time,
How do I write a batch file to instruct my winxp to look in the listA
and auto (i) ftp the script over (ii) run it, (iii) ftp back the result to my winxp.

The person who got the answer, I will call on the name of my LORD to bless HIM 100 fold, if you do not have the answer, I will pray to my LORD to bless you 100 fold plus the knowledge to give me the answer. HE is a good GOD. :-)
  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Posts: 2700
  • Loc: Somewhere outside the box in Sarasota, FL.

Post 3+ Months Ago

learner:
http://www.filedudes.com/Auto_FTP_Manag ... 31303.html

Trial software to send to multiple back ends at once.

Either that or load cygwin (a unix command shell on windows) and utilize shell scripts or perl.
  • learner2008
  • Born
  • Born
  • learner2008
  • Posts: 4

Post 3+ Months Ago

#I got another question.
#From host1 send file to host2,host3.....host100
#in a script I can do like this

for xhost in host2 host3 ..... host100
do
Ftp1="user user1 thepasswod\n put dummyfile1\n"
echo "$Ftp1 quit" | sftp -b ${xhost}
done

#the interactive mode has been taken care of.
-----------------------------------------------------
#now I wish to use ssh to do a date in these server:

for xhost in host2 host3 ..... host100
do
ssh -a host2 date
done

#but the next thing is it prompts for Password:, I am using a for loop to run the #command in 100 server, and I have to enter password 100 times.
#is there a way something like this?

echo "$thepasswod\n" | ssh -a host2 date (this line does not work.
  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Posts: 2700
  • Loc: Somewhere outside the box in Sarasota, FL.

Post 3+ Months Ago

We use dssh regularly across varied geography with great success.

http://bashcurescancer.com/dssh-executi ... hosts.html
  • learner2008
  • Born
  • Born
  • learner2008
  • Posts: 4

Post 3+ Months Ago

Hi Daemonguy,

I am using HP-UX

my little trial script:
------------------------------
#!/usr/bin/expect -f
spawn ssh ${host} date
expect "Password:"
send "john3.16"

My trial run:
------------------------------
xx[2]: spawn: not found.
/usr/lib/dld.sl: Can't find path for shared library: libtcl.sl
/usr/lib/dld.sl: No such file or directory
xx[3]: 25289 Abort(coredump)
xx[4]: send: not found.


I think my server do not have spawn or /usr/lib/dld.sl
------------------------------
where do I download them?

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 59 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.