KShell regular expresion


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting KShell regular expresion
# 1  
Old 11-29-2009
KShell regular expresion

Hi,

I would like to know if the parameter i am passing to a shell script is contain
the following charachter : ASM.
I belive that i should use regular expresion here.
Can one help ?

Bellow is the "if statment" i need to fix with the reg exp:

if [ ${SID} != '+ASM' ]; then
#echo "IT IS AN RDBMS INSTANCE TYPE"
fi
Thanks
# 2  
Old 11-29-2009
Code:
SID="ASM"

TX5XN:/home/brad>[[ ${SID} == +("ASM") ]] && echo yes
yes
TX5XN:/home/brad>[[ ${SID} == "ASM" ]] && echo yes   
yes
TX5XN:/home/brad>[[ ${SID} == ASM ]] && echo yes  
yes

# 3  
Old 11-29-2009
What is the + for in your if-statement?

Code:
$ SID=someASMtext
$ [[ "$SID" = *ASM* ]] && echo yes
yes

# 4  
Old 11-29-2009
@OP: Your statement is correct, but you need to uncomment the echo command otherwise it will not work (there needs to be some kind of command, or you can use : instead (NOP)). It is best to use quotes around ${SID} so that the test won't break when SID is empty.
Code:
SID="+ASM"

Code:
if [ "${SID}" != '+ASM' ]; then
  echo "IT IS AN RDBMS INSTANCE TYPE"
fi

Code:
if [ "${SID}" = '+ASM' ]; then
  echo "IT IS AN ASM INSTANCE TYPE"
else

# 5  
Old 11-29-2009
Assuming ksh93 ....
Code:
SID="+ASM"

if [[ $SID == "+ASM" ]]
then
    echo "Yes"
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help with Kshell Script!

I am an AIX noobie, and have a question around an AIX 5.2 script that I need to run. Security Audit requires us to have no World Writable files on our server, but every time we restart the Domino server on AIX it re-flags two files as World Writable. I have a little script that I created that... (5 Replies)
Discussion started by: Nebs
5 Replies

2. Shell Programming and Scripting

String search using Regular Expresion

Hi, I am getting a string in the file, I want to parse the srting and extract the percentage from the string. Sample string are - ASAD112_sd12.34%adnmfk ASAsds_1.34%adnmfk ASAdf 2 sd12.34%adnmfk ASAD112_sd 12.34% adnmfk ASAD112_sd12.34% adnmfk I want to extract the numeric value... (3 Replies)
Discussion started by: meetvipin
3 Replies

3. Shell Programming and Scripting

Help on the regular expresion =~

my $hw_plf_desc = `grep hw_platform $NODE_CFG_FILE`; if($hw_plf_desc =~ /Netra X4270 X4446A M2 /) Could someone explain the use of =~ .... this works only for perl . What is the alternate for the same in shell . Could any one convert this to shell script (7 Replies)
Discussion started by: frintocf
7 Replies

4. Shell Programming and Scripting

if expresion syntax error

#! /bin/csh set umr=UMR foreach i ( `ls`) set file_nm=$i set bh_nm=`echo $file_nm | cut -d"_" -f2` if($bh_nm !=$umr) then { set bh_ext=`echo $file_nm | cut -d"_" -f4` set bh_num_nm="$bh_nm $bh_ext a .txt" mv $file_nm $bh_num_nm } ... (1 Reply)
Discussion started by: jdsignature88
1 Replies

5. Shell Programming and Scripting

Substring operation in kshell

Hi, Please let me know how to perform the substring operation in kshell. If i have line like below 238923893282389034893489458945904589045454903490 i would like to retrieve the position 7 to 19, how to do this in kshell? (1 Reply)
Discussion started by: informsrini
1 Replies

6. Shell Programming and Scripting

Regular expresion

Here's my script read number if echo $number | grep "" I want this "if" statement to return true only when numbers without letters is matched. For example 45 - true, 923 - true, r5 - false, tg/f - false and so on. In this script even a single digit number like "3" returns false. Thanks. (1 Reply)
Discussion started by: eXPlosion
1 Replies

7. Shell Programming and Scripting

help in if expresion

Hi All, Is my script still error?? i try to running and still error?? need help (1 Reply)
Discussion started by: justbow
1 Replies

8. AIX

Kshell scripts and timing

Hello everyone, I have a script thats acting funky, what I would like to do is report to a file, how long its taking to get to certain area's, in seconds. For example. -- Start timer -- Run unix command 1 -- Run unix command 2 -- Stop timer -- Report Seconds -- etc etc Is there a way... (3 Replies)
Discussion started by: dbridle
3 Replies

9. Shell Programming and Scripting

Variable regular expresion in awk.

:confused: Is there any way to use in awk a regular exprexion with a format not previusly known? I mean something like /VAR/ ,obviously VAR is the variable exprexion. Thak you all in advance. (4 Replies)
Discussion started by: Klashxx
4 Replies

10. UNIX for Dummies Questions & Answers

regular expresion question

I receive windows files via the internet on my solaris server. Since unix doesn't handle blanks well I change the blanks to ? which works just fine. I take these files and ftp them to windows so our analysts can work with them. Recently I received a file with the following structure: ... (3 Replies)
Discussion started by: gillbates
3 Replies
Login or Register to Ask a Question