01-18-2006
Shell script to calc sum of bytes used by files
I'm looking to create a Korn Shell script that, if given a directory as an arg, will calc bytes used by all files in the given directory and display that info. If no command line arg is given the program is to calc and display the bytes used by all the files in the pwd.
Example output:
/export/home/me> ./filesizes /export/home
6325832
Thanks...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT DEBIAN
ns_link
ns_file(3aolserver) AOLserver Built-In Commands ns_file(3aolserver)
__________________________________________________________________________________________________________________________________________________
NAME
ns_chmod, ns_cp, ns_cpfp, ns_ftruncate, ns_link, ns_mkdir, ns_rename, ns_rmdir, ns_symlink, ns_truncate, ns_unlink - File manipulation com-
mands
SYNOPSIS
ns_chmod option ?arg arg ...?
ns_cp option ?arg arg ...?
ns_cpfp option ?arg arg ...?
ns_ftruncate option ?arg arg ...?
ns_link option ?arg arg ...?
ns_mkdir option ?arg arg ...?
ns_rename option ?arg arg ...?
ns_rmdir option ?arg arg ...?
ns_symlink option ?arg arg ...?
ns_truncate option ?arg arg ...?
ns_unlink option ?arg arg ...?
_________________________________________________________________
DESCRIPTION
ns_chmod filename mode
Change a file's access permissions. ns_chmod changes the specified file's permissions to mode, in the same manner as the Unix
chmod(1) command-line utility.
ns_cp -preserve file1 file2
Copy one file to another. ns_cp copies the contents of file1 to file2, just like the Unix "cp" command. The default directory is
the home directory for the server. If -preserve is specified, the copied file will retain the creation time, modification time,
owner, and mode of the original file, just like the Unix "cp -p" command.
ns_cpfp fileid1 fileid2 ?nbytes?
Copy a specified number of bytes from one file to another. ns_cpfp copies information from one file (fileid1) to another (fileid2).
If you specify a number of bytes in the nbytes argument, only the specified number of bytes will be copied. By default, the entire
file is copied.
ns_ftruncate fileid ?length?
Truncate an open file to a specified length. ns_ftruncate causes the open file specified by fileid to have a size of length bytes.
If length is not specified, it causes the file to have a size of zero bytes. The file must be open and be a regular file.
ns_link ?-nocomplain? filename1 filename2
Create a link. ns_link creates a link named filename2 that points to the file specified by filename1. If the link fails, a Tcl
error is generated, unless -nocomplain is specified.
ns_mkdir path
Create a directory. ns_mkdir creates the directory named PATH, just like the Unix mkdir command. By default, under Unix the direc-
tory is created with the file permissions set to 0755 (rwxr-xr-x.). These permissions can be modified by setting the umask parameter
for the server.
ns_rename file1 file2
Rename a file. ns_rename renames the first file (file1) to the file name specified by file2. Make sure that the files and the
directories in which the files exist are read/write accessible to the username that's running the AOLserver.
ns_rmdir path
Remove a directory. ns_rmdir removes the directory named path, just like the Unix rmdir command. The directory must already be
empty.
ns_unlink [-nocomplain] filename
Remove a file. ns_unlink attempts to remove the file filename. If -nocomplain is not passed in and the removal fails, a Tcl error
is generated.
ns_truncate filename ?length?
Truncate a file to a specified length. ns_truncate causes the file specified by filename to have a size of length bytes. If length
is not specified, it causes filename to have a size of zero bytes. The file must exist and be a regular file.
ns_unlink [-nocomplain] filename
Remove a file. ns_unlink attempts to remove the file filename. If -nocomplain is not passed in and the removal fails, a Tcl error
is generated.
SEE ALSO
ns_chmod, ns_cp, ns_cpfp, ns_ftruncate, ns_link, ns_mkdir, ns_rename, ns_rmdir, ns_symlink, ns_truncate, ns_unlink
KEYWORDS
AOLserver 4.0 ns_file(3aolserver)