Posts

Showing posts from July, 2022

command line / bash variable in awk command

 This is how we use a command line / bash variable (named num) in a awk command. We define an awk  variable 'var' with -v option. This also shows use of BEGIN block. awk -F, -v var=$num 'BEGIN{srand(var)} {print $1","$2","rand()}' file_name 

Change nameserver entries in resolve.conf

 We can directly change the contents of the file but they dont seem to be in effect. So I added Google's nameserver in the file as follows :  $ sudo cat /etc/resolvconf/resolv.conf.d/base  nameserver 8.8.8.8 nameserver 8.8.4.4 And then updated the file as follows :  $ sudo resolvconf -u   we can also just update /etc/resolve.conf and it will be in effect immediately. $ sudo sed -i '1 i\nameserver 8.8.8.8\nnameserver 8.8.4.4' /etc/resolv.conf  To remove the changes : $ sudo sed -i '1,2d' /etc/resolv.conf