First Query:
i have a text file username.txt contains
user1
user2
user3
My Bash file is as follows > test.sh
#!/bin/bash
# REMOVE user which donot have any COMBLIMIT
num=0
cat /tmp/username.txt | while read users
do
num=$[$num+1]
USERID=`echo $users | awk '{print $1}'`
SRVID=`mysql -uxxx -pxxx -e "use radius; SELECT srvid FROM radius.rm_users WHERE rm_users.username = '$USERID';" |awk 'FNR == 2 {print $1}'`
COMBLIMITCHECK=`mysql -uxxx -pxxx -e "use radius; SELECT limitcomb FROM rm_services WHERE srvid = '$SRVID';" |awk 'FNR == 2 {print $1}'`
if [[ $COMBLIMITCHECK -eq "1" ]]; then
echo "$USERID have Quota limit = 1"
else
echo "$USERID have no Quota Limitations = 0 , So removing it from the users list."
sed -i '/\$USERID\>/d' /tmp/username.txt
fi
done
sed -i '/\$USERID\>/d' /tmp/username.txt
>> This command in bash is not removing the exact matched username. I want to delete line which contains specific username (variable).
Second Query:
File contains following lines
cOke is bad
diet-COKE
cokeisgood
How can i cat this file and search for any word which contains "coke" in it regardless of lower or upper case.