Enough of the bloat! You don’t need to use cat, grep, head, sed, etc. All you need is AWK!

REFERENCED:

WANT TO SUPPORT THE CHANNEL?
💰 Patreon:
💳 Paypal:
🛍️ Amazon:
👕 Teespring:

SOCIAL PLATFORMS:
🗨️ Mastodon:
💬 IRC: irc://freenode #distrotube
👫 Reddit:

DT ON THE WEB:
🕸️ Website:
🌐 Gopherhole: gopher://distro.tube
📁 GitLab:

FREE AND OPEN SOURCE SOFTWARE THAT I USE:
📽️ Open Broadcaster Software:
🎬 Kdenlive:
🎨 GIMP:
🔊 Audacity:
💻 VirtualBox:

Your support is very much appreciated. Thanks, guys!

Nguồn: https://codeigniterbrasil.com

Xem thêm bài viết khác: https://codeigniterbrasil.com/lap-trinh-linux/

24 Comments

maximilian2000

April 16, 2020

Just one day after Luke Smith's video.
https://youtu.be/82NBMvx6vFY

Reply

Anders Jackson

April 16, 2020

From the Professor K from awk(1) talks about grep(1): https://www.youtube.com/watch?v=NTfOnGZUZDk

Reply

Knack Wurst

April 16, 2020

https://youtu.be/_q6Uj4X_knc?t=713 quote: "you can use awk to just print out every line in a file, … although that's kinda dumb, you would probably just use cat or something like that" I like your video and that you have encouraged me to go out and learn awk. Though I would have to disagree with replacing cat and grep with awk. I understand I could just use awk to accomplish what those programs do, however, am I supposed to remove cat and grep from my system and possibly break something that depends on them and expects them to exist? Maybe I should write aliases for cat but then if I am mimicking cat `alias cat=awk '{print}'` why not just use cat if I need a simple dump of the file. Though looking at the man page for cat reveals its simplicity, perhaps it should not be shipped by default.

Reply

Sergio Díaz Nila

April 16, 2020

Now you filthy mortal, shut up about GREP and get ready to listen to the Grand Brian Kernighan https://www.youtube.com/watch?v=NTfOnGZUZDk

Reply

D M

April 16, 2020

UNIX philosophy, use programs that do just one thing but they do it very well, and compose them via pipes or scripts to do what you need.

awk is doing too much and misses the point

to use those programs that do 1 thing to do that 1 thing and not another.

`cat` works in pair with `split`, you use `split` to split a single file into multiple files "aa ab ac ad" then you work with them compress them do whatever the fuck you want with them and when you are finished you do `cat aa ab ac ad > file` to get file back at you.

one use case could be spliting a sensitive file into multiple parts, process them separately (compression, cryptography, etc), and send the parts through different channels to the destiny so in the destiny they process them back and cat them back together in the original file.

Reply

Sergio Díaz Nila

April 16, 2020

why use awk when we can use perl/ruby/python/cl/guile/st/haskell? for everything.

the answer is very simple, because UNIX philosophy is to have programs that do one thing very well.

cat is meant to concatenate files and print them to the STDOUT so you can use the result in some other place, it's goal isn't to print in the terminal anything to read, that would be the pager.

Reply

Semjon Kerner

April 16, 2020

I can tell you why people cat foo| grep bar. Because it is the number one example for pipes and almost no tutor ever tells them to read manpages and understand what is going on there.

Reply

Akami Channel

April 16, 2020

Why awk when you can python!? : )

Reply

Akami Channel

April 16, 2020

If you have a long chain of commands, it may assist in readability to cat file | at the beginning.

Reply

Christopher Iwen

April 16, 2020

awk '{print $0} (NR==11){exit}' new.sh seems easier to understand and use than what you used for the head example . great video by the way!!

Reply

Vanderfleet Martin

April 16, 2020

I believe that the Unix philosophy is small single purpose tools that do one thing well. That is why you would use grep instead of awk, not to mention that the grep command line was very much simpler and easier to remember than the awk equivalent. That said, this was a very interesting video on how the same things can be accomplished with different tools.

Reply

ARI ATH YF

April 16, 2020

Isn't avoiding to mention Luke's name as the source of the vid a bit insulting?

On the topic, what about performance?
Some tools are lighter than others that's why they fit well the use case.

Reply

kungfumachinist

April 16, 2020

Blargh! Captain Pedantic here… it's not "case insensitive" it's "case indifferent". It's the same difference as "uninterested" and "disinterested".

Reply

Kenny Heimbuch

April 16, 2020

Amazing that AWK has been around since 1977!

Reply

Steve Spirk

April 16, 2020

Awk is 671KB, plus 34K for the links from /usr/bin/awk -> /usr/bin/gawk. Cat, grep, sed, head, and tail are 475KB combined. Awk is teh B|0@t!

Reply

Platinum Claridge

April 16, 2020

Advocates using Unix programs… then proceeds to recommend using one program for everything. Hmmm. Derek, I usually enjoy your videos, but you completely misunderstood the point Luke was making in his video. Might want to rewatch it.

Reply

zeyad kenawi

April 16, 2020

bat is the coolest

Reply

Daniel Huston

April 16, 2020

I was hoping to learn something about AWK itself. Instead, you spend too much time disparaging CAT & GREP.

Reply

dranenko

April 16, 2020

Master this is reveling to me now I'll use AWK for my log and Metadata work.

Reply

Mayur Chavhan

April 16, 2020

AWK for print file content?!! I prefer "MORE" tools.

Reply

Ron Obvious

April 16, 2020

Why use cat? Well, cat <filename> is a lot easier to type out than awk '{print $0}' <filename>. The awk version of case insensitive grep is even worse since you have to explicitly call out each character that might be in both upper and lower case. awk does have some really useful stuff though. I'll have to dig into it further.

Reply

Jan Schmitt

April 16, 2020

Thanks for the comparison but to me it remains more tedious to use awk before ripgrep, grep…you name it..in most cases. Anyway still learned something new, thanks for that.

Reply

Antonov Scheeeschslav

April 16, 2020

I like this channel

Reply

Mastan J

April 16, 2020

Even I have this kind of doubt in my mind

Reply

Leave a Reply