- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- kornshell
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-11-2003 11:51 AM
07-11-2003 11:51 AM
kornshell
example:
test1=[[ 0 < 1 ]]
and
test1 will be assigned the value of 0 since this expression evaluates to true. Can I use eval? I tried but to no avail.
I also have another question:
I have a string test2="ab"
example:
if [[ $test2? = "abc" ]] ; then
echo "equal"
fi
which should print equal. I was trying this but it wouldn't matched.
thanks so much guys!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 11:57 AM
07-11-2003 11:57 AM
Re: kornshell
if [[ $test2? = "abc" ]] ; then
echo "equal"
fi
Should have double quotes around the var also and I believe single square brackets:
example:
if [ "$test2" = "abc" ] ; then
echo "equal"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 12:05 PM
07-11-2003 12:05 PM
Re: kornshell
if [[ $test2? = "abc" ]] ; then
echo "equal"
fi
should be:
if [[ ${test2}c = "abc" ]] ; then
echo "equal"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 12:27 PM
07-11-2003 12:27 PM
Re: kornshell
versions newer then 88, ie newer then what is one hp-ux, has a builtin true command. it does nothing and always has an exit code of 0. similiarly with false except it has an exit code of 1.
the version on hp-ux usually implements these as an alias. i've used the /usr/bin/true and false commands at times. as an example.
notDone=/usr/bin/true
a=a
# this will stay in the while loop until
# the letter b is input
#
while $notDone
do
if [ $a = b] ;then
notDone=/usr/bin/false #drops out of while loop
else
print "type in a letter"
read answer
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2003 01:30 AM
07-14-2003 01:30 AM
Re: kornshell
[[ 2 -gt 0 ]]
A=$?
You can use double brackets to evaluate arithmetic operations:
A=$(( 2>0 ))
Remember that:
a) arithmetic symbols as '>', '>=', '<', '<=' and bitwise operators (&,|,>>,<<) are only available using double brackets
echo $(( 1 << 4 )) # prints 16
b) relational operators && and || (instead of -a and -o used in test) are available using both double square brackets and double brackets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2003 01:38 AM
07-14-2003 01:38 AM
Re: kornshell
when (( ... )) evaluates a conditional expression (for instance, (( 2>1 )) ) computes
1 when it is TRUE
0 when it is FALSE
BUT the return value is
0 when it is TRUE
1 when it is FALSE
Run the following examples:
$ (( 2<3 )) && echo true || echo false # prints true
$ echo $(( 2<3 )) # prints 1