08-03-2010
comparing filesize in unixscript
Well i was trying to code some script where it was required to compare the file size..
i am using solaris 5.10
to get the filesize i used:
Filesize=`du -k temp/Final | awk '{print $1}' | sed 's/ //g'`
now i need to do
if filesize not equal to 0
then
do something
fi
i coded it as:
Filesize=`du -k temp/Final | awk '{print $1}' | sed 's/ //g'`
if [$Filesize -ne 0]
then
[the logic here]
fi
But its not getting successfully executed.
log says
Filesize=1
+ [1 != 0]
filename.sh: [1: execute permission denied
or
Filesize=0
+ [0 != 0]
filename.sh: [0: execute permission denied
can anyone help me here? its somewhat urgent for me. Thanks
*temp/Final :: temp is directory under which Final is the filename of which i need to compare the filesize with 0 and act
Last edited by egunda; 08-03-2010 at 05:18 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I know in php if you use the function filesize it will return the size of the file in bytes, but is there an easy way to get the size in MB.
Cheers (2 Replies)
Discussion started by: jmg5
2 Replies
2. Shell Programming and Scripting
How do I identify if there is any content in a file?
If there is nothing in a specified file, I'd like to send an email indicating that there is nothing to report.
Any help appreciated. (3 Replies)
Discussion started by: Cameron
3 Replies
3. UNIX for Dummies Questions & Answers
I saw some stuff in the search results on this - but nothing specific.....
I have a significant number of files (c. 300) which are output from a large process that I run. These are compared with a 'baselined' set of files - so I can quickly see if there are differences based on the sizes of the... (2 Replies)
Discussion started by: peter.herlihy
2 Replies
4. Shell Programming and Scripting
Hello everybody it's me again.
I have a procces that is writing in a 'file1' automatically but i want to truncate 'file1' to a filesize 'x' that mean if the 'file1' size is 'x' i want to delete the first lines while the last lines are being writed, that have sence?
in the process are an... (1 Reply)
Discussion started by: Lestat
1 Replies
5. UNIX for Dummies Questions & Answers
Hey guys.
What I need to do is this:
I need to find files that have a certain filesize (for this case a file size of 0 (zero) )
When I find this file with a filesize of zero I need to echo a statement that tells the user to delete it and not to delete it if the filesize is greater than... (3 Replies)
Discussion started by: ndoggy020
3 Replies
6. Shell Programming and Scripting
I want to know if there is any unix command to view the size of the file?
eg.
i have a directory letter
in this i have file a,b,c,d,e.
i just want to know the size of file d and not any other. (3 Replies)
Discussion started by: infyanurag
3 Replies
7. Shell Programming and Scripting
Hello,
I have a script that should store file size in a variable $filesize.
I don't know what is the best way to do it.
I tried
ls -lt myfile.txt | sed something >$filesize
but I don't know how to use sed to get filesize. I know that the owner of the file is root and then we have some... (6 Replies)
Discussion started by: pppswing
6 Replies
8. Shell Programming and Scripting
I am having problems with finding the filesize with this in my script:
filesize=`ls -l | awk '$5=0'`
if ; then
ls -l | awk '{print $9 " " $5}'
if ; then
echo "Would you like to delete this file? (y/n)"
if yes do this
elif no do this
fi
fi
else... (7 Replies)
Discussion started by: akeenabawa
7 Replies
9. Solaris
How do I check for any file size limitations in a directories ?
I remember my administrator had set a file limitation for a certain directory. I would like to know how I can check that. Thank you. (2 Replies)
Discussion started by: Leion
2 Replies
10. Shell Programming and Scripting
Hi,
I want to check file size in unix, based on file size I am going to execute appropriate command.
I tried below, but getting the error.
System details –
Machine hardware: sun4u
OS version: 5.9
if ( -s $f1 ) then
echo "filename exists and is > 0 bytes"
else
echo "filename... (7 Replies)
Discussion started by: rahulbahulekar
7 Replies
LEARN ABOUT OSX
dynamic_pager
dynamic_pager(8) BSD System Manager's Manual dynamic_pager(8)
NAME
dynamic_pager -- external storage manager for dynamic pager
SYNOPSIS
dynamic_pager [-F filename] [-S filesize] [-H high-water-trigger] [-L low-water-trigger] [-P priority]
DESCRIPTION
The dynamic_pager daemon manages a pool of external swap files which the kernel uses to support demand paging. This pool is expanded with
new swap files as load on the system increases. It is contracted when the swapping resources are no longer needed. The dynamic_pager daemon
also provides a notification service for those applications which wish to receive notices when the external paging pool expands or contracts.
OPTIONS
-F The base name of the filename to use for the external paging files. By default this is /private/var/vm/swapfile.
-H If there are less than high-water-trigger bytes free in the external paging files, the kernel will signal dynamic_pager to add a new
external paging file.
-L If there are more than low-water-trigger bytes free in the external paging files, the kernel will coalese in-use pages and signal
dynamic_pager to discard an external paging file. Low-water-trigger must be greater than high-water-trigger + filesize.
-P This option is currently unimplemented.
-S The fixed filesize [in bytes] to use for the paging files. By default dynamic_pager uses variable sized paging files, using larger
sized files as paging demands increase. The -S, -H and -L options disable that default and cause dynamic_pager to use a series of
fixed sized external paging files.
FILES
/private/var/vm/swapfile* Default external paging files.
/Library/Preferences/com.apple.virtualMemory.plist Configuration file.
XML PROPERTY LIST KEYS
The following keys can be specified in the configuration file. Please see plist(5) for more information about property list files.
UseEncryptedSwap <boolean>
This optional key activates encrypted swap (aka Secure VM), so that all data is encrypted before being written to a swap file. The default
is on for portable computers and off for other computers.
Mac OS X July 8, 2003 Mac OS X