Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Shell script to calc sum of bytes used by files Post 96178 by matrixmadhan on Wednesday 18th of January 2006 09:59:35 AM
Old 01-18-2006
sum the 5th column of ls -l.

Code:
# !/usr/bin/ksh

if [ $# -eq 0 ]
then
dir="."
else
dir=$1
fi

tot=`ls -l $dir | awk -F" " 'BEGIN {sum=0} {sum+=$5} END {print sum}'`
echo "$tot bytes"

exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to convert file_size from bytes to megabytes

Hi All, OS:AIX 64 bits. Requirement is to convert file_size from bytes to megabytes through shell script as below: export DBALIST="xyz@rediffmail.com" ls -ltr abcd.txt > file_size.result export file_size=`awk -F" " '{ print $5 }' file_size.result` if ] then mailx -s "File abcd.txt... (3 Replies)
Discussion started by: a1_win
3 Replies

2. Shell Programming and Scripting

Shell script to copy a log file if it exceeds 5000000 bytes

Hi, on unix box, under /local/home/userid/logs folder, apps generated the following files sw_warn.log sw_error.log eaijava.log if there any application specific errors, the above file will keep growing. if the file exceed 5000000 bytes, I would like to have a shell script which do... (6 Replies)
Discussion started by: lookinginfo
6 Replies

3. Shell Programming and Scripting

Shell script to sum every 3 values

I am looking for an easy way to calculate the sum of three values (*-12, *-01, *-02) which are contained after a comma (,). I have found an awk command that will sum every 3rd value, but I am not interested in the values before the comma (,). awk '{s+=$1}NR%3==0{print s;t+=s;s=0}'I am only... (8 Replies)
Discussion started by: ncwxpanther
8 Replies

4. Shell Programming and Scripting

Sum up values of columns in 4 files using shell script

I am new to shell script.I have records like below in 4 different files which have about 10000 records each, all records unique and sorted based on column 2. 1 2 3 4 5 6 --------------------------- SR|1010478|000044590|1|0|0| SR|1014759|000105790|1|0|0| SR|1016609|000108901|1|0|0|... (2 Replies)
Discussion started by: reach.sree@gmai
2 Replies

5. Shell Programming and Scripting

Shell script to find the sum of argument passed to the script

I want to make a script which takes the number of argument, add those argument and gives output to the user, but I am not getting through... Script that i am using is below : #!/bin/bash sum=0 for i in $@ do sum=$sum+$1 echo $sum shift done I am executing the script as... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

6. Shell Programming and Scripting

Bash script to find the number of files and identify which ones are 0 bytes.

I am writing a bash script to find out all the files in a directory which are empty. I am running into multiple issues. I will really appreciate if someone can please help me. #!/bin/bash DATE=$(date +%m%d%y) TIME=$(date +%H%M) DIR="/home/statsetl/input/civil/test" ... (1 Reply)
Discussion started by: monasharma13
1 Replies

7. UNIX for Dummies Questions & Answers

X bytes of 0, Y bytes of random data, Z bytes of 5, T bytes of 1. ??

Hello guys. I really hope someone will help me with this one.. So, I have to write this script who: - creates a file home/student/vmdisk of 10 mb - formats that file to ext3 - mounts that partition to /mnt/partition - creates a file /mnt/partition/data. In this file, there will... (1 Reply)
Discussion started by: razolo13
1 Replies

8. Shell Programming and Scripting

Shell script - entered input(1-40 bytes) needs to be converted exactly 40 bytes

hello, suppose, entered input is of 1-40 bytes, i need it to be converted to 40 bytes exactly. example: if i have entered my name anywhere between 1-40 i want it to be stored with 40 bytes exactly. enter your name: donald duck (this is of 11 bytes) expected is as below - display 11... (3 Replies)
Discussion started by: shravan.300
3 Replies

9. Shell Programming and Scripting

Script Shell: Count The sum of numbers in a file

Hi all; Here is my file: V1.3=4 V1.4=5 V1.1=3 V1.2=6 V1.3=6 Please, can you help me to write a script shell that counts the sum of values in my file (4+5+3+6+6) ? Thank you so much for help. Kind regards. (3 Replies)
Discussion started by: chercheur111
3 Replies

10. Shell Programming and Scripting

Shell script count lines and sum numbers from multiple files

I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines: It counts the number of lines: egrep -i String file_name_201611* |... (5 Replies)
Discussion started by: Elly
5 Replies
SVN_CHECKOUT(3) 							 1							   SVN_CHECKOUT(3)

svn_checkout - Checks out a working copy from the repository

SYNOPSIS
bool svn_checkout (string $repos, string $targetpath, [int $revision], [int $flags]) DESCRIPTION
Checks out a working copy from the repository at $repos to $targetpath at revision $revision. PARAMETERS
o $repos - String URL path to directory in repository to check out. o $targetpath - String local path to directory to check out in to Note Relative paths will be resolved as if the current working directory was the one that contains the PHP binary. To use the calling script's working directory, use realpath(3) or dirname(__FILE__). o $revision - Integer revision number of repository to check out. Default is HEAD, the most recent revision. o $flags - Any combination of SVN_NON_RECURSIVE and SVN_IGNORE_EXTERNALS. RETURN VALUES
Returns TRUE on success or FALSE on failure. NOTES
Warning This function is EXPERIMENTAL. The behaviour of this function, its name, and surrounding documentation may change without notice in a future release of PHP. This function should be used at your own risk. EXAMPLES
Example #1 Basic example This example demonstrates how to check out a directory from a repository to a directory named calc: <?php svn_checkout('http://www.example.com/svnroot/calc/trunk', dirname(__FILE__) . '/calc'); ?> The dirname(__FILE__) call is necessary in order to convert the calc relative path into an absolute one. If calc exists, you can also use realpath(3) to retrieve an absolute path. SEE ALSO
svn_add(3), svn_commit(3), svn_status(3), svn_update(3), SVN documentation on svn checkout. PHP Documentation Group SVN_CHECKOUT(3)
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy