Sponsored Content
Top Forums Shell Programming and Scripting Question on using "[[ ]]" in lieu of IF Construct Post 302285085 by cfajohnson on Saturday 7th of February 2009 03:07:24 AM
Old 02-07-2009
Quote:
Originally Posted by sunpraveen
Unix gurus,

I have a piece of code as below.

Code:
[[ -n ${ORACLE_SID} ]] && INST="${ORACLE_SID}" || INST="${TWO_TASK}"


The [[ ... ]] syntax is non-standard. In almost all cases, you can use the standard [ ... ].
Quote:

I know that the above code can be used in lieu of an IF construct. I also know that the above code can be extended for the "true" condition to include more than one command (as below):

Code:
[[ -n ${ORACLE_SID} ]] && INST="${ORACLE_SID}" && echo "INST=${INST}" || INST="${TWO_TASK}"

But I am unable to extend the "false" condition to include more than one command.

Code:
[ -n "$ORACLE_SID" ] && {
 INST=$ORACLE_SID"
 echo "INST=$INST"
} || {
 INST=$TWO_TASK
 echo "INST=$INST"
}

However, you should note that, in the general case, that is not the same as:

Code:
if [ -n "$ORACLE_SID" ]
then
 : do whatever
else
 : do something else
fi

A simplified example:

Code:
[ -n "$qwerty" ] && false || echo "FAIL!"

"FAIL!" will always be printed. The command after || is executed if either of the preceding commands fails.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. UNIX and Linux Applications

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or question of my own) is: Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Discussion started by: talipk
0 Replies

3. UNIX for Advanced & Expert Users

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses... Here is the configuration of my system: * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or... (1 Reply)
Discussion started by: talipk
1 Replies

4. Shell Programming and Scripting

Why stderr file descriptor redirection makes ksh's "select" construct hang.

I am trying to use one global declaration --> "exec 2>$ERR" to capture all stderr outputs that may occur anywhere in my script. Then close it at the end of the script using --> "exec 2<&-" I am using KSH on Solaris 8. KSH Version M-11/16/88i If I comment two "exec .." statements in the... (11 Replies)
Discussion started by: kchinnam
11 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

(CSH basic construct) "@" query

While going through a script, i came across few syntax which I am not aware of what they exactly means. @ cnt = 1 @ num_all = `echo $var` What is the significance of "@" here. What is it called? (3 Replies)
Discussion started by: animesharma
3 Replies

7. Solaris

"Estream construct failed" Error on Solaris i86pc

Hi Guys, From past some days, I am getting an error in /var/adm/messages which is as shown below. XXXXX02:/# cat /var/adm/messages |tail Sep 16 15:28:14 XXXX02 EV_AGENT: Agent Main --Estream construct failed. Err: EMULSocket::recv() Sep 16 15:31:49 XXXX02 EV_AGENT: Agent main --... (2 Replies)
Discussion started by: vivek.goel.piet
2 Replies

8. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
ACPI_WMI(4)						 BSD/i386 Kernel Interfaces Manual					       ACPI_WMI(4)

NAME
acpi_wmi -- ACPI to WMI mapping driver SYNOPSIS
To compile this driver into the kernel, place the following line in your kernel configuration file: device acpi_wmi Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): acpi_wmi_load="YES" DESCRIPTION
The acpi_wmi driver provides an interface for vendor specific WMI implementations (e.g. HP and Acer laptops). It creates /dev/wmistat, which can be read to get information about GUIDs found in the system. FILES
/dev/wmistat WMI status device. EXAMPLES
# cat /dev/wmistat GUID INST EXPE METH STR EVENT OID {5FB7F034-2C63-45E9-BE91-3D44E2C707E4} 1 NO WMAA NO NO AA {95F24279-4D7B-4334-9387-ACCDC67EF61C} 1 NO NO NO 0x80+ - {2B814318-4BE8-4707-9D84-A190A859B5D0} 1 NO NO NO 0xA0 - {05901221-D566-11D1-B2F0-00A0C9062910} 1 NO NO NO NO AB {1F4C91EB-DC5C-460B-951D-C7CB9B4B8D5E} 1 NO WMBA NO NO BA {2D114B49-2DFB-4130-B8FE-4A3C09E75133} 57 NO NO NO NO BC {988D08E3-68F4-4C35-AF3E-6A1B8106F83C} 20 NO NO NO NO BD {14EA9746-CE1F-4098-A0E0-7045CB4DA745} 1 NO NO NO NO BE {322F2028-0F84-4901-988E-015176049E2D} 2 NO NO NO NO BF {8232DE3D-663D-4327-A8F4-E293ADB9BF05} 0 NO NO NO NO BG {8F1F6436-9F42-42C8-BADC-0E9424F20C9A} 0 NO NO NO NO BH {8F1F6435-9F42-42C8-BADC-0E9424F20C9A} 0 NO NO NO NO BI SEE ALSO
acpi(4), HISTORY
The acpi_wmi device driver first appeared in FreeBSD CURRENT. AUTHORS
The acpi_wmi driver was written by Michael Gmelin <freebsd@grem.de> Work has been inspired by the Linux acpi-wmi driver written by Carlos Corbacho See http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx for the specification of ACPI-WMI. This manual page was written by Michael Gmelin <freebsd@grem.de> BSD
June 30, 2009 BSD
All times are GMT -4. The time now is 07:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy