I would like to check if the given ip address is already in the config file. But /etc/ can only be accessed by root, and I'm running the a script as admin. It seems I can't just do sudo
#!/bin/bash
CLIENT_WG_IPV4="10.66.66.1"
DOT_EXISTS=$(sudo grep -c "$CLIENT_WG_IPV4/22" "/etc/wireguard/wg0.conf")
if [[ ${DOT_EXISTS} == '0' ]]; then
...
fi
I get the error message:
grep: /etc/wireguard/wg0.conf: Permission denied
What can I do?