0

I have got a variable containing \ and cannot grep properly.

I am making a snippet to connect to wifi spots.

  1. I scan all wifi spots and keep that info in /tmp/wifi.spots

  2. then copy the spot I am interested in (with mouse right click)

  3. then paste the spot name into an input command:

  4. 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.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
achille
  • 173
  • 1
  • 3
  • 12

0 Answers0