- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- if statement for file size
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 05:24 AM
02-13-2004 05:24 AM
if [ file size -gt 60 ]
than
blah
fi
Doesnot work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 05:30 AM
02-13-2004 05:30 AM
SolutionFNAME=myfile
typeset -i10 SZ=$(ls -l ${FNAME} | awk '{print $5}')
if [[ ${SZ} -gt 60 ]]
then
blah
blah
fi
The only built-in test is
if [[ -s ${FNAME} ]]
which tests id ${FNAME exists and has a size > 0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 05:31 AM
02-13-2004 05:31 AM
Re: if statement for file size
if [ file size -gt 60 ]
then
blah
fi
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 05:38 AM
02-13-2004 05:38 AM
Re: if statement for file size
Would get you all the files > then 60 bytes.
Best regards,
Kent Ostby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 06:00 AM
02-13-2004 06:00 AM
Re: if statement for file size
if [ $? -lt 1 ]
then
blah
fi
Best regards,
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 06:09 AM
02-13-2004 06:09 AM
Re: if statement for file size
Will print files of 60 bytes and more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 06:14 AM
02-13-2004 06:14 AM
Re: if statement for file size
LOGSIZE=$((`du -k $LOG | awk '{print $1}'`))
Assuming $LOG is the name of the file.
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 06:28 AM
02-13-2004 06:28 AM
Re: if statement for file size
if [ $(( $LOGSIZE > $LOGSIZELIMIT )) != 0 ] ; then
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 06:36 AM
02-13-2004 06:36 AM
Re: if statement for file size
In perl there is: -s
Usage example:
perl -e 'while (<*>) { print -s," $_\n" if (-s > 6000)}'
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2004 06:49 AM
02-13-2004 06:49 AM
Re: if statement for file size
If your file might be in that range, you can alter Clay's shell solution to divide the size by 1024, for instance, to get the size in kb in your awk part (awk '/file$/{printf "%d\n",$5/1024}).
You could also use things like 'wc -b
ls -s is also a solution, but will get you the size of the file in filesystemblocksize, which might not be what you want.