Why does this if match although it shouldn't?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why does this if match although it shouldn't?
# 1  
Old 02-23-2018
Why does this if match although it shouldn't?

Hi everyboy,

I am a little confused and can't understand why I get a positive match in the following case.

Shell Script section
Code:
echo $SHELL
echo "Server type = ${SERV_TYPE}"
if [[ "${SERV_TYPE}" == ["sapapp+oradb" || "sapapp"] ]]; then
    echo "foor"
    echo -e $(_date) "${cinfo}INFO: ${crst}Checking SAP memory on ${HOST}"

This is the output
Code:
/bin/bash
Server type = hanadb
foor
2018-02-23 12:21:41 INFO: Checking SAP memory on test0815

My need is that the if statement checks variable SERV_TYPE and exactly matches "sapapp+oradb" or "sapapp". So that in my example this should not match, but somehow it does Smilie

Could anyone please help me to understand what is going on here and what I have done wrong?

Kind Regards,
h1kelds

Last edited by h1kelds; 02-23-2018 at 08:02 AM..
# 2  
Old 02-23-2018
Methinks you want to use
Code:
if [[ "${SERV_TYPE}" == "sapapp+oradb" || "${SERV_TYPE}" == "sapapp" ]]; then

This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Data match 2 files based on first 2 columns matching only and join if match

Hi, i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file I have tried with join and awk and i keep getting blank outputs or same file is there an easier way than what i am... (4 Replies)
Discussion started by: axis88
4 Replies

2. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. UNIX for Dummies Questions & Answers

Users of own group shouldn't be able to delete

Oracle Linux 6.5 oracle user's primary group is oinstall and its secondary group is dba,asmdba,asmoper. For the below created directory, I want the users belonging to dba,asmdba,asmoper to be able create, read and execute files but not delete them. How can I achieve that. If I use 775 as... (5 Replies)
Discussion started by: kraljic
5 Replies

4. UNIX for Dummies Questions & Answers

This awk should work, shouldn't it?

Heyas Trying to parse a tempfile, but somehow i mess up. To my understand, this should work... Plain: tail -n1 out.tmp 1 81.5M 1 1066k 0 0 359k 0 0:03:52 0:00:02 0:03:50 359k I want to get the 81.5M, so i'd assume it'll be $2 for awk.... tail -n1 out.tmp | awk... (24 Replies)
Discussion started by: sea
24 Replies

5. Shell Programming and Scripting

Match pattern1 in file, match pattern2, substitute value1 in line

not getting anywhere with this an xml file contains multiple clients set up with same tags, different values. I need to parse the file for client foo, and change the value of tag "64bit" from false to true. cat clients.xml <Client type"FIX"> <ClientName>foo</ClientName>... (3 Replies)
Discussion started by: jack.bauer
3 Replies

6. Shell Programming and Scripting

Script outputing out numbers when it shouldn't

i suspect the issue is with the IFS part. I have a script that reads a file. the problem here is that, when i run the script, it outputs a bunch of numbers. i know what these numbers are, but i dont understand why they're being sent to the screen. as you can see below, everything should be... (5 Replies)
Discussion started by: SkySmart
5 Replies

7. Solaris

Particular user account shouldn't be locked after entering wrong passwd specfic no. times

Hi all In my system we have implemented user lockout feature after 3 failure attempt if he tries to login directly or if he run the any command through sudo and enter wrong password thrice. Now I have requirement in which particular user account shouldn't be locked when he run the command... (1 Reply)
Discussion started by: sb200
1 Replies

8. Shell Programming and Scripting

Delimited data contains line feeds where they shouldn't be

I have some data, each record (line) ends with a line feed (\n). Each field is pipe (|) delimited. 1|short desc|long text|2001-01-01 01:01 2|short desc| long text |2002-02-02 02:02 3|short desc| long text | 2003-03-03 03:03 4|short desc | long text | 2004-04-04 04:04 ... (10 Replies)
Discussion started by: ericdp63
10 Replies

9. UNIX for Dummies Questions & Answers

why is this so hard when it shouldn't be?

All I ask is one thing: 1. Where can i dl unix and the driver for my modem? right now i have win xp HP notebook, and bellsouth is my provider with a westell modem. (2 Replies)
Discussion started by: velious
2 Replies
Login or Register to Ask a Question