- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Unix ls command part II
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
Discussions
Discussions
Forums
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
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
тАО07-18-2001 12:47 PM
тАО07-18-2001 12:47 PM
Previous message ...
I was wondering if the ls command can list all files in a current directory with file size that is greater than some number and less than some number? ...
Actually, this is part of a script I am writing. Now, how would i be able to check if anything is returned? ie.
...
elif [ $1 -lt $2 ] ; then
find size ... -print
if [ (pseudo) find size = 0 ] ; then
echo "No such files!"
fi
fi
...
I guess the problem is that I don't know the command i would use in (pseudo) ... any ideas?
gracias ...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:06 PM
тАО07-18-2001 01:06 PM
SolutionIn your previous post I offered you the following:
If you want to use 'ls' and limit the results returned by filesize, consider this method:
# ls -l /tmp|awk '$5 > 1000 && $5 < 3000 {print $0}'
...this will return all files in the /tmp directory whose size is greater than 1000 and less than 3000.
The fifth ($5) field returned is the size of the file. If you want to pipe this command string into a file, you could then test whether that file was empty or not.
You can also add the -R' option to the 'ls' command to make the search recursive.
The bulk of this solution I suggested to you in your first post [to which you assigned *no* points, I might add].
...JRF...
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:13 PM
тАО07-18-2001 01:13 PM
Re: Unix ls command part II
One very easy way to do this (if you are willing to limit yourself to 512-byte block resolution) is to use 2 -size args to find connected with -a (and).
-size +1 will find all files greater than 1 block -size -5 will find all files less than 5 blocks.
LO=1
HI=5
find . \( -size +${LO} -a -size -${HI} \)
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:25 PM
тАО07-18-2001 01:25 PM
Re: Unix ls command part II
if [ (pseudo) find size = 0 ] ; then
echo "No such files!"
fi
with (borrowing from Clay's example)
find . \( -size +${LO} -a -size -${HI} \) >/dev/null && echo "No such files!"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:25 PM
тАО07-18-2001 01:25 PM
Re: Unix ls command part II
I'm not sure what you are asking. Do you still need help with the command to show all files less than a number and greater than another number? It almost sounds like this is a component to a larger script.
Or, are you wanting some script writing help? If so, it would be helpful if you could post more of your script. Also, a little more information on what you want the final script to do would be helpful.
Thanks,
Jared
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2001 01:32 PM
тАО07-18-2001 01:32 PM
Re: Unix ls command part II
Use the following-
if [ `find . \( -size +${LO} -a -size -${HI} \) -print` ] ; then echo "No such Files!" ; fi
- Tags:
- find