Sponsored Content
Top Forums Shell Programming and Scripting Help with calculating size of files. Post 302348394 by EAGL€ on Friday 28th of August 2009 06:09:16 AM
Old 08-28-2009
Mate I have got what you need as i've been working with backup size issues recently so I assume that you want to calculate size of some spesific files (i give 3 example of file u change them according to extension of your files) and besides lets say u want to consider the modification date of files ( for ex:files that are created earlier than 3 days):

Code:
find . \( -name "*.gz" -o -name "*.tar" -o -name "*.rar" \) -mtime -3 -exec ls -l {} \;| awk '/^-/ {total += $5} END {printf "%15.0f\n",total}'

$5 in awk represents the 5th column (size column) that is result of "ls -l" command.

regards

Last edited by EAGL€; 08-28-2009 at 07:14 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Scripts for calculating size and remaining space of a directory automatically.

I would like to create a script for calculating size and remaining space of a directory automatically every 24 hours, then send an email to report to the admin. * POSIX and PERL are preferred. Can anyone help, please? (1 Reply)
Discussion started by: leonall
1 Replies

2. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies

3. Programming

calculating size of int

Hi, Is there any way to calculate the size of a built in data type without using 'sizeof' operator? I also don't have the option to read it from std .h file. regards Apoorva Kumar (10 Replies)
Discussion started by: apoorvasharma80
10 Replies

4. Shell Programming and Scripting

compare files and calculating

Hi everybody: Could anybody tell me how can I do this task in AWK language. I've two files (file1 & file2) where file1 its last row it has first field value equal that the first row in file2, thyen I want calculate the difference in other fields, and this values apply in file2. This is: file1:... (6 Replies)
Discussion started by: tonet
6 Replies

5. UNIX for Dummies Questions & Answers

CAlculating page file size

hello dont know if this is the correct forum for this post but i have a question. i am revising for a exam on operating systems and i have the question... A system has a 32bit virtual address divided into 2kbyte pages and each entry in the page table is 6 bytes in length. what is the size... (0 Replies)
Discussion started by: Fortune
0 Replies

6. AIX

calculating the size of the luns using script

Hi This is the lspv output of my server : cbspsdb01 #lspv hdisk0 00c7518d2d512fd4 cdgvg active hdisk1 00c7518d2dcbc9d6 cdgvg active hdisk2 00c7518dcda9199a appvg active hdisk3... (1 Reply)
Discussion started by: samsungsamsung
1 Replies

7. Shell Programming and Scripting

Calculating average of 100 different files of same size

Hey guys..... I have many files (lets say 100 or more) of same size, and I want to create a new output file and calculate the average of first row fifth column in all files and print it in first row of output file, then 2nd row fifth col in all 100 files and print it in 2nd row of output... (1 Reply)
Discussion started by: CAch
1 Replies

8. Shell Programming and Scripting

Calculating average from files

I have some files with the following contents.I would like to calculate average of fifth column. How can I do this with awk? file1 cat 95.9 152 78.0 17.9 rat 67.1 153 36.5 30.6 dog 81.4 154 68.1 13.3 dog 92.0 155 55.5 36.5 rat 73.8 156 23.9 49.9 file2 rat... (4 Replies)
Discussion started by: avina
4 Replies

9. UNIX for Beginners Questions & Answers

Calculating size of backups

hi everyone i have a backup share mounted with me on solaris 10 which have daily backups. everyday i need to calculate all individual sizes of files and need to report somewhere. e.g i have .rman 7backup files daily . what i need that is there any commnd or variation of du command which can add... (1 Reply)
Discussion started by: janakors
1 Replies

10. UNIX for Beginners Questions & Answers

Calculating size of backups

hi everyone i have posted this query but i dont where it has gone i am posting again . my issue is that i have many backup files in a backup nfs share and i need to calculate it size just by adding their individual file sizes which is repetitive jobs. so is there any command or variation of du... (1 Reply)
Discussion started by: janakors
1 Replies
size(1) 							   User Commands							   size(1)

NAME
size - print section sizes in bytes of object files SYNOPSIS
size [-f] [-F] [-n] [-o] [-V] [-x] filename... DESCRIPTION
The size command produces segment or section size information in bytes for each loaded section in ELF object files. size prints out the size of the text, data, and bss (uninitialized data) segments (or sections) and their total. size processes ELF object files entered on the command line. If an archive file is input to the size command, the information for each object file in the archive is displayed. When calculating segment information, the size command prints out the total file size of the non-writable segments, the total file size of the writable segments, and the total memory size of the writable segments minus the total file size of the writable segments. If it cannot calculate segment information, size calculates section information. When calculating section information, it prints out the total size of sections that are allocatable, non-writable, and not NOBITS, the total size of the sections that are allocatable, writable, and not NOBITS, and the total size of the writable sections of type NOBITS. NOBITS sections do not actually take up space in the filename. If size cannot calculate either segment or section information, it prints an error message and stops processing the file. OPTIONS
The following options are supported: -f Prints out the size of each allocatable section, the name of the section, and the total of the section sizes. If there is no section data, size prints out an error message and stops processing the file. -F Prints out the size of each loadable segment, the permission flags of the segment, then the total of the loadable segment sizes. If there is no segment data, size prints an error message and stops processing the file. -n Prints out non-loadable segment or non-allocatable section sizes. If segment data exists, size prints out the memory size of each loadable segment or file size of each non-loadable segment, the permission flags, and the total size of the segments. If there is no segment data, size prints out, for each allocatable and non-allocatable section, the memory size, the section name, and the total size of the sections. If there is no segment or section data, size prints an error message and stops processing. -o Prints numbers in octal, not decimal. -V Prints the version information for the size command on the standard error output. -x Prints numbers in hexadecimal, not decimal. EXAMPLES
The examples below are typical size output. Example 1 Producing size information example% size filename 2724 + 88 + 0 = 2812 Example 2 Producing allocatable section size information example% size -f filename 26(.text) + 5(.init) + 5(.fini) = 36 Example 3 Producing loadable segment size information example% size -F filename 2724(r-x) + 88(rwx) + 0(rwx) = 2812 ... (If statically linked) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWbtool | +-----------------------------+-----------------------------+ SEE ALSO
as(1), cc(1B), ld(1), ar.h(3HEAD), a.out(4), attributes(5) NOTES
Since the size of bss sections is not known until link-edit time, the size command will not give the true total size of pre-linked objects. SunOS 5.11 16 Oct 1996 size(1)
All times are GMT -4. The time now is 07:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy