I have got a variable containing \
and cannot grep properly.
I am making a snippet to connect to wifi spots.
I scan all wifi spots and keep that info in
/tmp/wifi.spots
then copy the spot I am interested in (with mouse right click)
then paste the spot name into an input command:
make some other things:
a. grep /tmp/wifi.spots to select the ap with the best Quality (=70/70 if possible)
b. grep /tmp/wifi.spots to configure wpa_conf if there is a password
Here is my code:
iwlist <wifi device> scan > /tmp/wifi.spots
grep /tmp/wifi.spots | grep -i essid
read -rp "what essid you want to connect to?" ESSID
Here comes the problem: Let's say I want to connect to a spot called "G\xC3\x92TIC". In order to grep correctly in /tmp/wifi.spots,I need to rewrite the ESSID variable to: G\\xC3\\x92TIC
So what I need is the following. After having pasted my essid in ESSID, I need to check it out for any '\' and rewrite the variable if necessary before going through step 4.