Sponsored Content
Full Discussion: Summing file size and output
Top Forums UNIX for Advanced & Expert Users Summing file size and output Post 302257533 by ramkrix on Wednesday 12th of November 2008 11:27:46 AM
Old 11-12-2008
Summing file size and output

SmilieHi,

I need to find the sum of size of specific files in my directory

Say for ex,
mydir$ ls -ltr
permisssion links user group size date time filename

I want to display the sum of size of filenames having pattern "TS55". Note file size in this directory is near 400 MB.

mydir$ ls -ltr | grep "TS55" | awk '{sum+=$5} END {print sum}'
1.52757e+11


I want to have the output in full decimal form and not in exponential form like this. Please advice on this.
Thanks,
Ramkrix
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare file size from a output file from a script

Hi guys, firstly I'm working on SunOS 5.10 Generic_125100-10 sun4u sparc SUNW,Sun-Fire-V240 I've made a script to compress two directory and then send them to an other server via ftp. This is working very well. Inside theis script I decide to log usefull data for troubleshooting in case of... (7 Replies)
Discussion started by: moustik
7 Replies

2. UNIX for Dummies Questions & Answers

ls -l output file size

Hi Guys, I'm working on various platforms: Solaris 8 HP Tru64 RH Linux I'm on the HP Tru64 system and I've got to audit a particular directory for large files that are no longer being used. If I do an ls -l I get to see the file size. I'd just like to be clear on what that file size... (4 Replies)
Discussion started by: Stin
4 Replies

3. Shell Programming and Scripting

how to make a line BLINKING in output and also how to increase font size in output

how to make a line BLINKING in output and also how to increase font size in output suppose in run a.sh script inside echo "hello world " i want that this should blink in the output and also the font size of hello world should be big .. could you please help me out in this (3 Replies)
Discussion started by: mail2sant
3 Replies

4. Shell Programming and Scripting

Limiting output file size

Hi guys, I want to know if there is a way to check the current size of the file that I output "stuff" to. For example, if I run a command that outputs data (like another shell script or C program) and i do something like `./a.out &> tempfile.txt` within the script, I want to be constantly... (2 Replies)
Discussion started by: solaris7
2 Replies

5. Solaris

Script fails when generated output file reaches a particular size

Hi All, New to unix. Here is the problem. Running a script that extracts data from hyperion essbase and generates a file in unix. This script fails most of the times with a very low success rate. The data has increased a lot in the last few months resulting in the file being more than 2 gb. ... (2 Replies)
Discussion started by: noufalshaw
2 Replies

6. Shell Programming and Scripting

Output after a perl script gives a file with size zero.

Hi, I have a unix shell script which generates a flat file after connecting to Teradata servers to fetch tables and views and also picks up modified unix scripts from the specified paths. Later on the script calls a perl script to assign a value based on the type of object in the flat file which... (2 Replies)
Discussion started by: yohasini
2 Replies

7. UNIX for Dummies Questions & Answers

Summing lines in a file

Can anyone tell me how sum values in each record of a file and append that value to the end? For instance a typical record will be: FY12,Budget,771100,,,,,,,,,250,-250 I'd like the record to become FY12,Budget,771100,,,,,,,,,250,-250,0 which can be put into another file. Thank you. (6 Replies)
Discussion started by: LearningLinux2
6 Replies

8. UNIX Desktop Questions & Answers

Summing file sizes

I was just curious about how to sum the total file size of a certain type of file. For instance: $find . -name "*.aif" will print out the paths to each .aif file. Instead of printing, how could one sum the total space used by all of the aif files? Thanks! Please use code tags (3 Replies)
Discussion started by: Alexander4444
3 Replies

9. UNIX for Dummies Questions & Answers

Create csv with output filenames and file size

Hello All, Here is seeking a bit of help in trying to solve a problem. I am required to create a csv file as shown below: output.csv -> output_1,output_2,output_3,...,output_<N> filename1:20,filename2:30,filename3:30,...,filename<N>:30 by listing output_1, output_2,... , output<N> as... (3 Replies)
Discussion started by: vkumbhakarna
3 Replies

10. Shell Programming and Scripting

Summing all fields in a file

I was playing around to see how stuff works, and was trying to sum all fields in a file. cat file 1 2 3 4 5 6 7 8 9 10 11 12 I made this script: awk 'BEGIN {OFS=RS}{$1=$1}{s+=$0} END {print "sum="s}' file This gives 15, why not 78? I test it like this awk 'BEGIN... (5 Replies)
Discussion started by: Jotne
5 Replies
sum(1)							      General Commands Manual							    sum(1)

NAME
sum - Displays the checksum and byte count in block-size (1024) units of a file SYNOPSIS
sum [-o | -r] [file...] The sum command reads file and calculates a 16-bit checksum and the byte count in block-size (1024) units in the file. If the file argu- ment is omitted, sum reads standard input. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: sum: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
[Tru64 UNIX] Uses an algorithm to compute the checksum using word-by-word computation. Uses an alternate algorithm to compute the check- sum (rigorous byte-by-byte computation rather than the word-by-word computation). [Tru64 UNIX] This is the default. OPERANDS
The file for which a checksum is to be computed. If this operand is omitted, standard input is used. DESCRIPTION
The checksum and number of blocks are written to standard output. The sum command is generally used to determine if a file that was copied or communicated over transmission lines is an exact copy of the original. The sum command writes the space used in 1024-byte units. [Tru64 UNIX] The checksum is calculated using a rigorous byte-byte computation by default. System V Compatibility [Tru64 UNIX] The checksum algorithms for the default sum command and the SVID 2 compliant sum command are reversed. The SVID 2 compliant sum command uses the word-by-word algorithm by default and uses the byte-by-byte algorithm if you specify the -r option on the command line. NOTES
The sum utility is marked LEGACY in XCU Issue 5. [Tru64 UNIX] The default algorithm is no longer the word-by-word computation algorithm. It was changed to the 4.3BSD default algorithm. The algorithms used may not be portable, that is, the same checksum may not be produced for the same input on different systems. Portable applications should use cksum. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To display the checksum of datafile and the number of blocks in this file, enter: sum datafile If the checksum of datafile is 1605 and if the file contains 3 blocks, sum displays: 1605 3 datafile ENVIRONMENT VARIABLES
The following environment variables affect the execution of sum: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: cksum(1), wc(1) Standards: standards(5) sum(1)
All times are GMT -4. The time now is 03:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy