have three big data file, however I just need to see the mentioned below one line form the all the file which has SERVER_CONNECTION Value
File 1
export SERVER_CONNECTION=//dvlna002:10001/SmartServer
File2
export SERVER_CONNECTION=//[SERVER_HOSTNAME]/SmartServer
File3
export SERVER_CONNECTION=//dvlna003/SmartServer
One varaible i.e Test=dvlna002
now my requirement is to compare the values
Condition 1 for file1 : compare variable "Test" with "dvlna002" (this come from file 1 by grep command see the script ) if matches return "SAME" else "NOT SAME"
Condition 2 for file2: compare variable "Test" with "[SERVER" (this come from file 2 by grep command see the script) if matches return "SAME" else "NOT SAME"
Condition 3 for file3: compare variable "Test" with "dvlna003" (this come from file 3 by grep command see the script) if matches return "SAME" else "NOT SAME"
Output Result should be
Condition 1 >> SAME
Condition 2 >> NOT SAME
Condition 3 >> NOT SAME
I want to first write in the script that entre the file name and on the basis of file name entred by user it should go to the respective IF condition
Example : like I entered File 1 then it should only go to Condition 1 which check for Test = "dvlna002" , if it satisfy it just send me output of "SAME"
As of now I have written the script which is like this, I am unable to but the logic where it decide on which if condition it should go
#!/bin/sh
Test=dvlna002
echo "enter the file name from File1, file2, file3"
read filename
a= grep "SERVER_CONNECTION" file1 |cut -c 28-35 |tail -1
b= grep "SERVER_CONNECTION" file2 |cut -c 28-35 |tail -1
c= grep "SERVER_CONNECTION" file3 |cut -c 28-35 |tail -1
if [ "$a" = "$Test" ]; then
echo "same"
else
echo "not same"
fi
if [ "$b" = "$Test" ]; then
echo "same"
else
echo "not same"
fi
if [ "$c" = "$Test" ]; then
echo "same"
else