Computing.Net > Forums > Unix > Adding file size & output to file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Adding file size & output to file

Reply to Message Icon

Name: hismail
Date: February 23, 2006 at 23:35:05 Pacific
OS: Sun Solaris 9
CPU/Ram: 4gig/3gig
Comment:

Hi
How can I add the 5 field (size of file) from list & out put to a file eg:
-rwxrwxr-x 1 root oracle 804252672 Feb 23 22:25 automate.zeda
-rwxrwxr-x 1 root oracle 594944 Feb 23 22:25 autopart.zeda
-rwxrwxr-x 1 root oracle 343950336 Feb 23 22:26 reports.zeda

804252672+594944+343950336=
Output sum to a file in current directory.

THANKS
Hamim



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: February 25, 2006 at 22:19:49 Pacific
Reply:

Provided everyting i a file in the current directory:

#!/bin/ksh

fsize=0
for i in *.zeda
do
set - $(ls -l $i)
fsize=$((fsize+$5))
done

echo $fsize > mynewfile


0
Reply to Message Icon

Related Posts

See More


script execution time cal... KSH help for retreiving a...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Adding file size & output to file

Awk output to file help www.computing.net/answers/unix/awk-output-to-file-help/7570.html

sending output to printer www.computing.net/answers/unix/sending-output-to-printer/4066.html

How to send mails from unix to lotus notes www.computing.net/answers/unix/how-to-send-mails-from-unix-to-lotus-notes/8390.html