I just want to know if it is possible to read a variable for searching patterns in a existing running bash script which accepts parameters from outside, for example in command-line. Here the example,
# /home/testexp.sh
#!/usr/bin/env bash
PATH=$(/usr/bin/getconf PATH || /bin/kill $$)
echo "$1" # The first parameter that has been set.
readfromfile=$(cat filename1)
if test "$1" = "$readfromfile" ;
then
echo "excellent"
else
echo "no no.."
fi
How can i use parameter variable expansion for searching patterns in $readfromfile variable ?
I want to do like:
./testexp.sh ${readfromfile:2:3}
Where i must say, it works only when $readfromfile is set and exported and it has been printed in script. Like:
echo "$1"
But i do not want to modify $1 parameter, i want to search for patterns in $readfromfile variable and bruteforce it when it is equal to $1 parameter.
Aucun commentaire:
Enregistrer un commentaire