- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: IF condition
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
07-25-2006 06:08 AM
07-25-2006 06:08 AM
if [ ! -f "$SOURCE/inven_file_cu.dat" -o -s "$SOURCE/inven_file_cu.dat" ]; then
echo 'Process the inventory data'
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2006 06:13 AM
07-25-2006 06:13 AM
Re: IF condition
-f file exists and is regular
-o or
-s file exists and is greater than zero bytes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2006 06:13 AM
07-25-2006 06:13 AM
Re: IF condition
-o Binary OR operator (-a has higher precedence than -o).
-s file True if file exists and has a size greater than zero.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2006 06:18 AM
07-25-2006 06:18 AM
Re: IF condition
-o OR
-s tests if the size of the file is greater than zero
the condition is contradictory and would never evaluate to true unless the negation sign ! is removed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2006 06:34 AM
07-25-2006 06:34 AM
Re: IF condition
Actually, it tests true if the file doesn't exist, or if the file exists and has size. If it were an "and" expression instead of an "or", then it would never evaluate to true...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2006 06:40 AM
07-25-2006 06:40 AM
Solution-f is true if a file exists _and_ it is a regular file
-s is true if a file exists _and_ its size is greater than zero
So, the condition would mean:
"If $SOURCE/inven_file_cu.dat is something other than a regular file, or if it is a file with greater-than-zero length, then process the inventory data".
"Something other than a regular file" would include a directory, a named pipe (created using "mknod
I have a feeling the creator of this condition might not have been aware of all the possible "not a regular file" choices... but without knowing more about the script it is impossible to be sure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2006 06:47 AM
07-25-2006 06:47 AM
Re: IF condition
thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2006 12:27 AM
07-26-2006 12:27 AM