- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- syntax of if in Ksh
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
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
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
тАО01-06-2004 11:20 PM
тАО01-06-2004 11:20 PM
syntax of if in Ksh
plz let me know the syntax of if in Ksh with or operator.is sytax for integer comparisions and string comparisions.
THANKS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 11:28 PM
тАО01-06-2004 11:28 PM
Re: syntax of if in Ksh
Check man ksh:
if then else elif fi
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2004 11:28 PM
тАО01-06-2004 11:28 PM
Re: syntax of if in Ksh
if expression
then
code
fi
comparisons are normally done with "test" which is also called "[" so
if [ $a > "abc" ]
then
echo "$a is alphabetically larger that abc"
fi
or for numerics
if [ $a -gt 10 ]
Alternatively, miss out the if altogether and rely on the && (and) and || (or) operators as in
[ $a -gt 10 ] && {
echo "$a is greater than ten"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 12:57 AM
тАО01-07-2004 12:57 AM
Re: syntax of if in Ksh
strings are compared vi > < and =
integers use -gt -lt -eq -ge -le
so you have tests like this:
if [[ "$String1" > "$String2" ]]; then
and
if [[ $Int1" -gt "$Int2" ]]; then
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 02:34 AM
тАО01-07-2004 02:34 AM
Re: syntax of if in Ksh
string == Pattern
true if string matches pattern Pattern.
Quote Pattern to treate it as a string.
= is obsolete and may be replaced in the future. Use == rather then =.
string != Pattern
string does not match pattern Pattern
string1 < string2
string1 comes before string2 in the collation order defined by the current locale
string1 > string2
string1 comes after string2 in the collation order defined by the current locale
for arithmetic expressions use ((....))
expression < expression
less then
expression > expression
greater then
expression <= expression
less then or equal to
expression >= expression
greater then or equal to
expression == expression
equal to
expression != expression
not equal to
the value of an expression with a comparison operator or a logical operator is 1 is non-zero (true), or 0 (false) otherwise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2004 06:29 AM
тАО01-09-2004 06:29 AM