awk basics

awk is a text processor that allows you to break down strings, especially in this article, by seperating them by white space

meaning, if you have a line of text such as the entries in fstab, which resemble:
/dev/sda1 /mnt/sda1 ext4


you can efficiently do, cat /etc/hosts | grep awk '{ print $1; }'
and it will print out /mnt/sda1
remember, computer architecture's numbers start at 0!

some notes:
REMEBER THE SINGLE QUOTE BEFORE THE CURLY BRACES!!
REMEMBER THE PRINT OPTION! ITS IN THE CURLY BRACES AFTER THE SINGLE QUOTE!
REMEMBER THE SEMI COLON AFTER EVERY COMMAND! the semicolon terminates commands!
and that awk can be piped or printed to the STDOUT macro

again, ill run the command, cat /etc/hosts | awk '{ print $2; }' and display the results on my page
the results are!

localhost
broadcasthost
localhost

this is from /etc/hosts, which has the contents:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

remember to run, debug, and test your scripts before releasing them or placing them into production!

also not sure why $1 didnt register as the hostnames in /etc/hosts

anyway, awk is a very powerful tool, seeing how you can have a configuration file you want to parse, or some kind of file or output from some program, can be parsed into segments using awk

whew. fucking public hospitals and their zyprexa

but lets say you do 'grep -I 'getaddrinfo' ~/.git/emacs/src/*c | awk '{ print $3; }' > output.txt && SCRIPT.SH output.txt
this takes grep, finds all instances of getaddrinfo in the source directory specificed, and breaks down each line and prints out the fourth statement seperateed by white spaces, including tabs, normal spaces, and overal space between entries in files

you can certainly use pipes, meaning you can take the output of like, dnf and prase it through grep and or awk, but this is true to the cause and yes, best used for analyzing source code

good luck!
unidef