Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 11 Dec 2016, 04:16
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » REQUESTS
How do I use grep with a variable? {SOLVED}
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
B.K. Johnson

Joined: 12 Oct 2009
Posts: 491

PostPosted: Fri 18 Mar 2016, 16:35    Post subject:  How do I use grep with a variable? {SOLVED}  

Hello
I could not find where to post this programming question, so apologies if I am in the wrong place. But if you can help, please do. Thanks.

Here goes:

/root/InterfacesList has the following lines
ESSID:"gynaecentre"
ESSID:"EDENVALE"
ESSID:"VALLEY HEALTH CARE SERVICES"
ESSID:"LENOX GAYLE"
ESSID:"ARRIS-7D72"
ESSID:"Nexxt_5B3BF8"
ESSID:"LIVING WATERS"
ESSID:"HP-Print-8C-ENVY 4500 series"

A script has:
Code:
TheEssid="LIVING WATERS"
     if (grep "LIVING WATERS" /root/Interfaceslist -c -q);then
             echo $TheEssid found
     else
        echo $TheEssid Not found
     fi

This code finds that LIVING WATERS is included in InterfacesList - returning LIVING WATERS found
I wish to use the variable TheEssid instead of hard-coding LIVING WATERS in the grep line.
How do I do this? Neither replacing LIVING WATERS with TheEssid nor with $TheEssid works nor does $(grep .....

_________________
B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM


Last edited by B.K. Johnson on Mon 26 Sep 2016, 13:52; edited 1 time in total
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 1588
Location: Germany

PostPosted: Fri 18 Mar 2016, 17:41    Post subject:  

Quote:
TheEssid="LIVING WATERS"
if (grep "LIVING WATERS" /root/Interfaceslist -c -q);then
echo $TheEssid found
else
echo $TheEssid Not found
fi


Quote:
TheEssid="LIVING WATERS"
if (grep "$TheEssid" /root/Interfaceslist -c -q);then
echo $TheEssid found
else
echo $TheEssid Not found
fi

_________________
RSH

T.O.P.L.E.S.S..

Das Schwert der Diffamierung ist stumpf geworden und der Schild der Ignoranz löchrig. Gut so! Cool Very Happy Laughing
Back to top
View user's profile Send private message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 491

PostPosted: Fri 18 Mar 2016, 18:41    Post subject:  

Thanks!
_________________
B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » REQUESTS
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0443s ][ Queries: 11 (0.0112s) ][ GZIP on ]