![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| A question/problem about oracle "tns listener" and "enterprise manager" | talipk | UNIX for Advanced & Expert Users | 1 | 12-03-2008 07:55 AM |
| A question/problem about oracle "tns listener" and "enterprise manager" | talipk | UNIX and Linux Applications | 0 | 12-01-2008 03:08 PM |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 04:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Actually, it's not the ""[[ ]]" construct nor the "[ ]" construct, but the && construct that does the trick. There is no standard way, however, of doing negation in the UNIX shell using the && || constructs. One can, however, do something like this:
Code:
not() {
"$@"
if [ $? = 0 ]; then return 1; else return 0; fi
}
# not true || echo false
false
# not false && echo true
true
Code:
# not true || { echo false; date; echo really false; false; } || echo Total failure.
false
really false
Total failure.
# not true || { echo false; echo really false; true; } && echo not a total failure.
false
really false
not a total failure.
You should be able now to do: Code:
command_A && { command_A_worked; command_A_worked_report; true; } || { command_A_failed; command_A_failed_report; false; }
|
|
|||||
|
Quote:
|
|
||||
|
Code:
TRUE="FALSE" [[ $TRUE = "TRUE" ]] && echo "true" || (echo "false"; echo "false2") false flase2 Now we change this to: Code:
TRUE="TRUE" [[ $TRUE = "TRUE" ]] && echo "true" || (echo "false"; echo "false2") true |
|
|||||
|
Quote:
Quote:
|
|
||||
|
Quote:
Code:
[ "$TRUE" = "TRUE" ] && echo "true" || (echo "false"; echo "false2") |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|