How to delete a network profile from etc/wpa_supplicant/wpa_supplicant.conf through command line / shell script

后端 未结 4 1953
甜味超标
甜味超标 2021-01-03 07:20

I have multiple wifi network ssid\'s saved in my etc/wpa_supplicant/wpa_supplicant.conf like shown below, can we delete a specific network from this wpa_supplicant.conf

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 08:04

    You can write it you're self. Some very ugly Quick-n-Dirty Code would be for example:

    file="/etc/wpa_supplicant/wpa_supplicant.conf"
    foo="$(cat "$file" | awk '/myssid3/ { flag=1 }; flag==0 { print $0 }; /network={/ { flag=0 }' )"
    if echo -e "$foo" | tail -1 | grep -q 'network={'; then
       foo=$(echo -e "$foo" | head -n -1)
    fi
    echo -e "$foo" > "$file"
    

提交回复
热议问题