PLAY PODCASTS
'awk' - a programming language for working on files - Video Man Pages

'awk' - a programming language for working on files - Video Man Pages

DistroTube on Odysee

January 1, 20268m 10s

Audio is streamed directly from the publisher (player.odycdn.com) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.

Show Notes

thumbnail

The 'awk command' is really an entire programming language used for working with files and text.

- Print a file (similar to 'cat'):
awk '{print}' path/to/file
OR
awk '{print $0}' path/to/file

- Print the 2nd field of each line:
awk '{print $2}' path/to/file

- Print the last field of each line:
awk '{print $NF}' path/to/file

- Search for lines containing 'string' and print the second field of those lines:
awk '/string/ {print $2}' path/to/file

- Use a different field separator (instead of space) and print 1st and 7th fields with a TAB in between:
awk -F ":" '{print $1 "\t" $7}' /etc/passwd

- Find a specific string in any column:
ps -ef | awk '{ if($NF == "/usr/bin/pipewire") print $0};'
NOTE We search if the last field is '/usr/bin/pipewire' and print the line.

- Search 1st field if it starts with 'b' or 'c', then prints the line:
awk '$1 ~ /^[b,c]/ {print $0}' .bashrc
NOTE The '~' character is the regex match operator.

- Use the 'substr' function to print each record from the 2nd character onward:
awk '{print substr($0, 2)}' .bashrc
NOTE It essentially prints the document but omits the first character of each line.

REFERENCED:
โ–บ https://gitlab.com/dwt1/vidman

WANT TO SUPPORT THE CHANNEL?
๐Ÿ’ฐ Patreon: https://www.patreon.com/distrotube
๐Ÿ’ณ Paypal: https://www.paypal.com/donate/?hosted_button_id=MW3ZFGS8Q9JGW
๐Ÿ›๏ธ Amazon: https://amzn.to/2RotFFi
๐Ÿ‘• Teespring: https://teespring.com/stores/distrotube

DT ON THE WEB:
๐Ÿ•ธ๏ธ Website: http://distro.tube
๐Ÿ“ GitLab: https://gitlab.com/dwt1
๐Ÿ—จ๏ธ Mastodon: https://fosstodon.org/@distrotube
๐Ÿ‘ซ Reddit: https://www.reddit.com/r/DistroTube/
๐Ÿ“ฝ๏ธ Odysee: https://odysee.com/@DistroTube:2

FREE AND OPEN SOURCE SOFTWARE THAT I LIKE:
๐ŸŒ Brave Browser - https://brave.com/
๐Ÿ“ฝ๏ธ Open Broadcaster Software: https://obsproject.com/
๐ŸŽฌ Kdenlive: https://kdenlive.org
๐ŸŽจ GIMP: https://www.gimp.org/
๐Ÿ’ป VirtualBox: https://www.virtualbox.org/
๐Ÿ—’๏ธ Doom Emacs: https://github.com/hlissner/doom-emacs

Your support is very much appreciated. Thanks, guys!
...
https://www.youtube.com/watch?v=cK1JMK7Ckq0