command line to show total size of files

Post November 7th, 2006, 11:51 pm

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


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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 7th, 2006, 11:51 pm

  • vijayan
  • Beginner
  • Beginner
  • No Avatar
  • Joined: 31 Jul 2006
  • Posts: 52
  • Loc: india
  • Status: Offline

Post November 8th, 2006, 3:06 am

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 .

Post November 8th, 2006, 3:35 am

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?
"I trust everyone, it is the devil in side them that I don't trust"
=======
http://mmughrabi.blogspot.com/
  • roca
  • Newbie
  • Newbie
  • No Avatar
  • Joined: 07 Nov 2006
  • Posts: 5
  • Status: Offline

Post November 8th, 2006, 4:42 pm

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.

Post November 8th, 2006, 8:08 pm

have you tried df ?
Image
"In a world without walls and fences, who needs Windows and Gates?"
  • learner2008
  • Born
  • Born
  • No Avatar
  • Joined: 21 Apr 2008
  • Posts: 3
  • Status: Offline

Post April 21st, 2008, 1:36 am

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
  • No Avatar
  • Joined: 21 Apr 2008
  • Posts: 3
  • Status: Offline

Post April 21st, 2008, 1:51 am

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
  • Mastermind
  • User avatar
  • Joined: 23 Jan 2004
  • Posts: 2301
  • Loc: Somewhere outside the box in RTP, NC.
  • Status: Offline

Post April 23rd, 2008, 2:30 pm

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.
"It's always a long day, 86,400 won't fit into a short."
  • learner2008
  • Born
  • Born
  • No Avatar
  • Joined: 21 Apr 2008
  • Posts: 3
  • Status: Offline

Post May 14th, 2008, 7:58 pm

#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.

Post Information

  • Total Posts in this topic: 9 posts
  • Moderator: Daemonguy
  • Users browsing this forum: No registered users and 100 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
 
 

© Unmelted Enterprises 1998-2008. Driven by phpBB © 2001-2008 phpBB Group.

 
 
 
 

Need a pre-made web design for your website?

Check out our templates here: Ozzu Templates


400+ FREE Website Templates. Download Now!