- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: put two conditional expressions in if
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
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
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
11-13-2011 07:36 PM - edited 11-15-2011 05:34 PM
11-13-2011 07:36 PM - edited 11-15-2011 05:34 PM
Re: put two conditional expressions in if
>the second form is more efficient because the '[[ ]]' is evaluated directly by the shell (Korn or POSIX) whereas the more traditional '[ ]' is evaluated by the external test(1) command
This is incorrect. test is documented as a builtin and tusc shows that ksh has [ ... ] builtin.
And especially since /usr/bin/test is just a Posix shell script that invokes the sh test builtin.
- Tags:
- Test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2011 03:21 AM
11-15-2011 03:21 AM
Re: put two conditions in if
@Dennis Handly wrote:>the second form is more efficient because the '[[ ]]' is evaluated directly by the shell (Korn or POSIX) whereas the more traditional '[ ]' is evaluated by the external test(1) command
This is incorrect. tusc shows that ksh has [ ... ] builtin.
And especially since /usr/bin/test is just a Posix shell script that invokes the builtin.
So to give it some sense to dig up this one - what would be the technical exact answer for the difference of
[ ] or [[ ]]
?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2011 05:26 PM - edited 11-15-2011 05:27 PM
11-15-2011 05:26 PM - edited 11-15-2011 05:27 PM
Re: put two conditional expressions in if
>what would be the technical exact answer for the difference of: [ ... ] [[ ... ]]
There are three ways to compare in a real shell:
1) Arithmetic expressions: (( )), only handles numbers, not strings
2) [ ... ] or test builtin
Compound expressions are composed with -a and -o. Use of () must be quoted.
Arithmetic expressions, without (( )), can be used in arithmetic comparison operators.
String = and != compare strings.
String < and > don't exist. (Treated as redirection.)
3) [[ ... ]]
Compound expressions are composed with && and ||. Use of () doesn't need to be quoted.
Arithmetic expressions can't be used in arithmetic comparison operators.
String = and != match patterns.
String < and > exist.
- « Previous
-
- 1
- 2
- Next »