Some very useful tips when working with IP addresses on the Internet.

Get the IPv6 address of a website very easily with this simple one-liner. jason@. PWD: ~. -bash. 3.2.57. 29 $> host ipv6.google.com | awk ‘FNR==2 {print $5}’ 2404:6800:4006:811::200ejason@. PWD: ~. -bash. 3.2.57. 29 $> host ipv6.google.com | awk ‘FNR==2 {print $5}’ 2404:6800:4006:811::200e This works just fine to get the required information. I am not sure … Read more

How to add a column heading with awk on Linux.

This very nice one-liner will print some information about your mounted drives on Linux and also print a column header to dress up the output. ┌──[[email protected]]─[~/Downloads] └──╼ ╼ $ df -Hla | grep "[0-9]% /" | awk -F, ‘NR==1 {print "Device","Capacity","Free","Usage","Percentage","Mount"} {gsub(/"/,""); print $1,$2,$4}’ | column -t Device Capacity Free Usage Percentage Mount dev 13G … Read more

Another way to get the actual IP address of your machine.

This is yet another way to get the actual IP address of your Linux machine on a LAN. This returns just the IP address of your Linux computer. jason@jason-Lenovo-H50-55:~$ ip a | awk ‘/inet / { print $2 }’ | sed -n 2p 192.168.1.4/24jason@jason-Lenovo-H50-55:~$ ip a | awk ‘/inet / { print $2 }’ | … Read more

Some awesome tricks with awk, grep and sed.

Reading a large text file and then finding all words that contain between 5 and 7 vowels. Notice I am not using cat. jason@Yog-Sothoth:~/Documents$ egrep ‘^([^aieou]*[aieou]){5,7}[^aieou]*$’ < pg768.txt | wc -l 284jason@Yog-Sothoth:~/Documents$ egrep ‘^([^aieou]*[aieou]){5,7}[^aieou]*$’ < pg768.txt | wc -l 284 Count the number of times a single word appears in a text file. jason@Yog-Sothoth:~/Documents$ egrep … Read more

Some interesting and useful Linux commands and BASH tricks.

A useful awk implementation to count the number of entries in the /etc/passwd file. john@deusexmachina:~$ sudo awk -F: ‘{ print $1 }’ /etc/passwd | wc -l 34john@deusexmachina:~$ sudo awk -F: ‘{ print $1 }’ /etc/passwd | wc -l 34 And the quintessential “Hello World” in Awk. john@deusexmachina:~$ awk ‘BEGIN { printf "%s, %s\n", "Hello", "World!" … Read more

How to search and replace text in a file with sed. Not using cat.

The sed command is very useful for searching and replacing text in a file. This is how to search for and replace a text string in a file. Homer@bejiitas ~ $ sed -i ‘s/&lt;main&gt;/&lt;mein&gt;/gi;’ my.cHomer@bejiitas ~ $ sed -i ‘s/&lt;main&gt;/&lt;mein&gt;/gi;’ my.c This is how to search and replace text in a file and leave a … Read more

Converting a comma delimited file to newline delimited. Using sed to perform the conversion.

The search and replace dialog in Gedit. I have used this to convert a comma-delimited file to a newline delimited file. I had saved a huge long list of IP addresses that I had to put into the ban list on my forums, and the list was comma-delimited, but the latest PHPBB software will not … Read more