Meaning of =~ in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Meaning of =~ in shell script
# 1  
Old 01-15-2017
Meaning of =~ in shell script

Please let me understand the meaning of following line in unix bash scripting .is =~ means not equal to or equal to .

Code:
if [[ $INFA_HOME =~ .*9.5.1.* ]]; then

    
      echo -e "pmcmd startworkflow -sv ${INTSERV} -d ${INFA_DEFAULT_DOMAIN} -uv INFA_DEFAULT_DOMAIN_USER" \
        "-pv INFA_DEFAULT_DOMAIN_PASSWORD -usdv INFA_DEFAULT_DOMAIN_SECURITY_DOMAIN" \
        "-f ${FOLDER} -osprofile $OSPF -paramfile ${PARAM_FILE} -wait" \
        "-rin ${INFA_RUN_ID} ${WORKFLOW};"

      pmcmd startworkflow -sv ${INTSERV} -d ${INFA_DEFAULT_DOMAIN} -uv INFA_DEFAULT_DOMAIN_USER \
        -pv INFA_DEFAULT_DOMAIN_PASSWORD -usdv INFA_DEFAULT_DOMAIN_SECURITY_DOMAIN \
        -f ${FOLDER} -osprofile $OSPF -paramfile ${PARAM_FILE} -wait \
        -rin ${INFA_RUN_ID} ${WORKFLOW};

      export WF_RET_VAL=$?
    else


Last edited by Scrutinizer; 01-15-2017 at 04:24 PM.. Reason: code tags
# 2  
Old 01-15-2017
Quote:
Originally Posted by harry00514
Please let me understand the meaning of following line in unix bash scripting .is =~ means not equal to or equal to .

if [[ $INFA_HOME =~ .*9.5.1.* ]]; then
That's the regular expression match operator. Which means what you have at the right of it is not globbing but a regular expression. Therefore .*9.5.1.* means match (almost) any character, zero or more times, followed by a nine, followed by (almost) any character, followed by a five, followed by (almost) any character, followed by a one, followed by (almost) any character, zero or more times.

Normally . (dot) will not match any line break characters.

Last edited by Aia; 01-15-2017 at 03:25 PM..
This User Gave Thanks to Aia For This Post:
# 3  
Old 01-15-2017
To add:
It is strangely written, it is equivalent to:
Code:
if [[ $INFA_HOME =~ 9.5.1 ]]; then

And I suspect the dots are a mistake and they meant literal dots, rather than "any character":
Code:
if [[ $INFA_HOME =~ 9\.5\.1 ]]; then

Which is equivalent to the following pattern match:
Code:
if [[ $INFA_HOME == *9.5.1* ]]; then

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

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What is the meaning of ## in UNIX shell script?

Hi All, I am new to unix shell scripting and I was documenting one of the unix script and encountered below statements - for ii in `ls -1rt /oracle/admin/MARSCOPY/ext_files/fpm-ifpm/*.small.txt | tail -1 | awk '{print $1}'` do smallssim=${ii##/oracle/admin/MARSCOPY/ext_files/fpm-ifpm/}... (2 Replies)
Discussion started by: shuklajayb4
2 Replies

2. UNIX for Dummies Questions & Answers

UNIX Script - snipet meaning?

What would the below code snippet mean? my ($_configParam, $_paramValue) = split(/\s*=\s*/, $_, 2); $configParamHash{$_configParam} = $_paramValue; (2 Replies)
Discussion started by: MaKha
2 Replies

3. UNIX for Dummies Questions & Answers

Meaning of awk script

what does this mean? awk '!a||a>$1 {a=$1} END {for (i in a) print a,i}' file (6 Replies)
Discussion started by: osama ahmed
6 Replies

4. UNIX for Dummies Questions & Answers

Meaning of script with echo, -d, -f1, -f2

Hello Friends, I am a new learner of Unix & need to understand below script as start up, Can anyone explain the meaning of each line listed below. Thanks for your time. #!/usr/bin/ksh PARAMS=$1 #echo "parms passed is $PARAMS @" STATUS=`echo ${PARAMS} | cut -d: -f1` JOBNAME=`echo... (9 Replies)
Discussion started by: DK2014
9 Replies

5. Linux

Shell ${1:-/etc/hosts} meaning

Hello. In some script, I saw: filename=${1:-/etc/hosts} if && ; then md5sum $filename else echo “$filename can not be processed” fi # Show the file if possible ls -ld $filename 2>/dev/null What does the first line means? In $filename I still got /etc/hosts. (2 Replies)
Discussion started by: lozicd3
2 Replies

6. Shell Programming and Scripting

Whats the meaning of set -e inside the script

Hi, I would like to ask about the meaning or purpose of set -e in the script bash, Does it mean if a wrong command in the script it will close or exit the script without continuation thats what happen if i set it in the terminal. Thanks in advance (3 Replies)
Discussion started by: jao_madn
3 Replies

7. Shell Programming and Scripting

meaning of & in sh shell

All, I have a line in my code like below , could any one please tell me what this actually mean what is the & doding there. I am in sh shell #!/bin/sh .............. mv &fname &III.tar.gz Thanks in Advance, Arun (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

8. UNIX for Dummies Questions & Answers

meaning of script

hello every one i want to know meaning of following line INST_PARA=$HOME/install/Install.Para SAVEMEDIUM=`awk '$2=="ArchiveSave"{print$4}' $INST_PARA` (4 Replies)
Discussion started by: kaydream
4 Replies

9. Shell Programming and Scripting

Meaning of this line in script

Can anyone explain me the meaning of line #2 in these lines of shell script: if ; then ${EXPR} " ${MACTIONS } " : ".* ${ACTION} " >/dev/null 2>&1 || die "$USAGE" else Sorry in case this is a trivial thing (I am not an expert in this). (3 Replies)
Discussion started by: radiatejava
3 Replies

10. UNIX for Dummies Questions & Answers

meaning of .& in shell

Hi , can anyone explain me the meaning of following line ". &13FNAME/version_encours/cfg/dfm.cfg" Regards (1 Reply)
Discussion started by: scorpio
1 Replies
Login or Register to Ask a Question