![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with simple korn scripting | samnyc | Shell Programming and Scripting | 4 | 01-15-2009 05:21 PM |
| simple issue.. | the_learner | UNIX for Advanced & Expert Users | 2 | 01-17-2008 04:44 PM |
| Unix Korn Shell Array Issue (SunOS) | Janus | Shell Programming and Scripting | 5 | 11-21-2006 08:19 PM |
| how to convert from korn shell to normal shell with this code? | forevercalz | Shell Programming and Scripting | 21 | 11-23-2005 02:18 AM |
| KORN Shell - Spawn new shell with commands | frustrated1 | Shell Programming and Scripting | 2 | 04-20-2005 03:23 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi. Code tags would make this readable (i.e. I see three errors at a glance, and it's not obvious if you typed this or pasted it).. The error is Code:
"$TEST"="Y" This would evaluate to true (as a non-empty string in itself.) Should be Code:
[ "$TEST" = "Y" ] (with spaces either side of the =) You also have a space between # and ! on line 1. |
|
||||
|
Also worth mentioning is that the preferred method for testing in Korn Shell is to use the [[ ... ]] construct instead of [ ... ]. There are several advantages, one of them is that it is much less picky about quoting and empty strings. For instance you could write your script without any double quotes: Code:
#!/bin/ksh TEST=N if [[ $TEST = Y ]]; then echo $TEST yes else echo no fi |
|
||||
|
There's something to be said for both [[ ... ]] and && || and something against. Code:
/root/tmp # [[ Y = Y ]] && paaa y || echo b -ksh: paaa: not found [No such file or directory] b Personally I prefer [ ... ] and quotes where needed, and an if [ ... ]; then else where the && part could itself fail. [[ ]] is testing the test, and leaves you not knowing necessarily why the inner test failed. Was the condition false? Was the variable not declared when it should have been? Just a preference. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|