I'm trying to write a bash script where I give a few variables as such:
var1="text1"
var2="text2"
var3="text3"
var4="text4"
var5="text5"
var6="text6"
I've tried it with one variable and the following script works fine:
if curl -s "https://web.net/list.txt" | grep $var1
echo $var1 is on the list
else
echo "FFHGFHFGHFHFG"
fi
I've been trying to input the other variables, which are hardcoded as those are not going to change, like this:
if curl -s "https://web.net/list.txt" | grep "$var1\|$var2"
if curl -s "https://web.net/list.txt" | grep '$var1|$var2'
I cannot remember all of the ways I've tried to do this, but that is my current attempt.
The idea is to find those values in a given site, output those values if the exist and nothing else.
This worked:
var1=head;var2=body;curl -s http://free.fr | grep "$var1\|$var2"
Ended up doing this:
var1=something1;var2=something2;var3=something3;var4=something4;var5=something5;var6=something6;
Code runs
var1=something1;var2=something2;var3=something3;var4=something4;var5=something5;var6=something6;
if curl -s https://website.net/text.txt | grep "$var1\|$var2\|$var3\|$var4\|$var5\|$var6"
then
echo $var1
echo $var2
else (...)
and so on.
After that I'm sending the results to a file for further analysis.
Thanks all.