In the following script I need to know if the configuration files is for a 2.4 or a 5.2 radio. This info is found in the filename so I'm trying to use grep -l 2.4 to find out if it's a 2.4 config file or not. If it's not the script sould go to the else clause but it's still echoing "5.2" file even when the file used as the command line argument is a 2.4 file.

garrett@bedroom ~$ ./testScript.sh system-2.4-AP.cfg
M2
M5
5.2 file
system-2.4-AP.cfg
empty-ssid
NanoBridge

Here's the script

FILE=${1}
SSID=$(grep -o empty-ssid ${FILE})
GATEWAY=$(grep -o 192.168.1.1 ${FILE})
#IP=$(grep -o ###.###.###.### ${FILE})
DEVICE="NanoBridge"

M2=" M2"
M5=" M5"

echo ${M2}
echo ${M5}

if [ $(ls ${FILE} | grep -l *2.4*) ]; then #{
        DEVICE=${DEVICE}${M2}
        echo "2.4 file"
else #} {
        #DEVICE="${DEVICE}${M5}
        echo "5.2 file"
fi #}

echo ${FILE}
echo ${SSID}
#echo ${FILE:${#FILE} - 2}
echo ${DEVICE}
#END#

Any ideas?

Got it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.