- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: put two conditions 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
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
тАО05-24-2006 06:04 AM
тАО05-24-2006 06:04 AM
if [ ! conditon 1 ] && [ condition " ]
];then
something
fi
thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 06:09 AM
тАО05-24-2006 06:09 AM
Re: put two conditions in if
In general:
if [[ "${A}" = "A" && "${B} = "B" ]] ; then
do something
else
do something else
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 06:10 AM
тАО05-24-2006 06:10 AM
Re: put two conditions in if
if [ -z "$VARIABLE" ] && [ -f /path/somefile]
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 06:12 AM
тАО05-24-2006 06:12 AM
Re: put two conditions in if
if [ != $TEST ] && [ != $TEST11 ] then
something
else
something
fi
(use for both conditions to be satisfied, if you need any one condition to be satisfied then use ||)
Chan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 06:13 AM
тАО05-24-2006 06:13 AM
Re: put two conditions in if
# X=1;Y=1;if [ $X -ne 1 ] && [ $Y -eq 1 ];then echo "ok";fi
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 06:24 AM
тАО05-24-2006 06:24 AM
Re: put two conditions in if
then
else
fi
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 07:02 AM
тАО05-24-2006 07:02 AM
Re: put two conditions in if
yes, I was looking for the "-a" option!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 07:07 AM
тАО05-24-2006 07:07 AM
Solutionif [ ${count} -ge 0 -a ${count} -lt 10 ]
then
else
fi
if [[ ${count} -ge 0 && ${count} -lt 10 ]]
then
else
fi
however, 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 expr command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 07:18 AM
тАО05-24-2006 07:18 AM
Re: put two conditions in if
if [[ ${count} -ge 0 && ${count} -lt 10 ]]
then
else
I thought that [[ was very ugly syntax, I didnt know the significian behind it..
appreciate it very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2006 09:46 AM
тАО05-24-2006 09:46 AM
Re: put two conditions in if
however, 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 EXPR command
should be:
however, 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 command
I was thinking one thing and typed another.