command line to show total size of files

  • mo_mughrabi
  • Student
  • Student
  • User avatar
  • Joined: Nov 07, 2006
  • Posts: 73
  • Status: Offline

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

Post November 7th, 2006, 11:51 pm

  • vijayan
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jul 31, 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 .
  • mo_mughrabi
  • Student
  • Student
  • User avatar
  • Joined: Nov 07, 2006
  • Posts: 73
  • Status: Offline

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?
  • roca
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Nov 07, 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.
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

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: Apr 21, 2008
  • Posts: 4
  • 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: Apr 21, 2008
  • Posts: 4
  • 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
  • Web Master
  • User avatar
  • Joined: Jan 23, 2004
  • Posts: 2673
  • Loc: Somewhere outside the box in Sarasota, FL.
  • 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: Apr 21, 2008
  • Posts: 4
  • 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.
  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Joined: Jan 23, 2004
  • Posts: 2673
  • Loc: Somewhere outside the box in Sarasota, FL.
  • Status: Offline

Post May 19th, 2008, 11:55 am

We use dssh regularly across varied geography with great success.

http://bashcurescancer.com/dssh-executi ... hosts.html
"It's always a long day, 86,400 won't fit into a short."
  • learner2008
  • Born
  • Born
  • No Avatar
  • Joined: Apr 21, 2008
  • Posts: 4
  • Status: Offline

Post May 22nd, 2008, 7:23 pm

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 56 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.