- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- doubt on while loop
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-04-2013 09:35 PM
02-04-2013 09:35 PM
doubt on while loop
Hi Gurus,
In a script i saw a while loop having below condition
while [[ -a $LOCK_FILE ]]
do { ===== done }
could you please tell me what this while condition will do. This LOCK_FILE is decalred as /tmp/audit.lock
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2013 10:34 PM
02-04-2013 10:34 PM
Re: doubt on while loop
The expression with double square brackets is a conditional expression that is parsed by the shell that is executing the script, so you should identify the shell that is used to run the script. Is it sh, ksh or something else?
For example, if the script is run using /sbin/sh or /usr/bin/sh in HP-UX, the sh-posix(1) man page lists all the possible conditions for a double-square-bracket conditional expression in a chapter titled Conditional Expressions.
In this case, -a <filename> means "the condition is true if <filename> exists". The test completely ignores the type of <filename>: it might actually be a directory, a symbolic link, a named pipe, or something else.
The loop will run as long as /tmp/audit.lock exists.
You might have been confused because in a single-square-bracket expression, the -a has a completely different meaning: it appears as <condition> -a <condition> and means that the expression is true only if both conditions are true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2013 12:33 AM
02-05-2013 12:33 AM
Re: question on conditional expression
Be careful if replacing it with -e, that's only for sh, not ksh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2013 12:35 AM
02-05-2013 12:35 AM
Re: doubt on while loop
Hi MK,
Thanks for the reply, the shell on which this script is executing is /usr/bin/ksh.
Regards