0

I have a first script for exemple :

test1.sh
$1='world'
var1="hello world"
echo $var1

So, i want a script shell, which execute test1.sh according to condition :

for exemple :

if  [ $1= world ]; 
  #execute test1.sh

i don't know how to rely the two shells, if you have any suggestions i ll be thankfull !

FelixJN
  • 13,566
  • 1
    Please find an answer to your question at the above link with a few more background info, too. Also $1 refers to the first argument after your script when you run it, you cannot define it as you do. bash script.sh world --> echo $1 in the script will return world. – FelixJN Dec 02 '19 at 15:48

1 Answers1

0

your if condition is ill-formated. You likely look for something like

#!/bin/bash
var1="hello world"
if [[ "$var1" == "$1" ]]; then echo $1 found; else echo $1 not found; fi

It will give output like

$ ./test1.sh "world world"
world world not found
$ ./test1.sh "hello world"
hello world found

You can call another bash script simply by its name like any normal programme or command