Of all the languages I barely know and seldom use, AWK is by far and away my favorite. I seldom need it, but when need arises, nothing else will do, so I open the manual and code. Plus I know two of the three gentlemen of the old school who wrote the original, and they are beyond awesome.
@borkomneСағат бұрын
Great video! I use awk a lot, and this what you presented here is what I use most of the time. There are 2 useful variables in awk I use often: NR - Number of current Record (useful to skip lines if there is a header in file) NF - Number of Fields in a current record (useful to figure out which lines are missing data)
@69k_goldКүн бұрын
Awk 2? Ah what a good version
@ismbks23 сағат бұрын
also known as C awk
@PotatoCider23 сағат бұрын
awk tuah
@JoshuaLambamm-l4f5 сағат бұрын
C what you did there
@animanaut7 сағат бұрын
imo one of the most overlooked feature of awk is the record separator. default is just newline, but some files have multiline entries or optional lines with additional information. It helped me once to parse log files that had regular log lines intermixed with lines of stacktraces.
@sanderdejong6621 сағат бұрын
I used to be an awk man, I never used sed. This vid brings back some memories 😊
@martins2246Күн бұрын
"awk and sed"...those two always seem to be together. I made a relational db with csv's, awk and sed in an airgapped secuirty zone.
@paulsander5433Күн бұрын
I hope you knew about the "join" and "sort" commands, too. A relational database would be hard to build without them.
@ismbks23 сағат бұрын
perl is awk + sed + the gold standard regex implementation
@martins224613 сағат бұрын
@@paulsander5433 probably? it was in c shell lol...wtf
@paulsander543311 сағат бұрын
@@martins2246 The sort and join programs aren't shell built-ins, so they're available in csh, too. And they work well in pipelines.
@mxm6506 сағат бұрын
Thanks for the quick overview! I wish this video had been out 10 days ago! I used to use awk a fair amount, but that was 15 or 20 years ago. I needed it last week, but I forgot all the syntax. It took a few hours of looking at man pages and searching to getting the basic syntax right. Worth it, though.
@milo3733Күн бұрын
great introduction to awk, i always knew you could print columns but not much else. made me realize i've probably piped sed outputs into awk where I could have done it all in the awk command
@Soupie626 сағат бұрын
Stock trading data includes: name, Open, High, Low, Close, and Volume. If you only care about Close, awkward will easily filter out unwanted data. If you only want particular shares, filter for lines starting with specific codes.
@SeanCCosgrove6 сағат бұрын
One of the features i find very powerful is that the field separator does not need to be a single character (put the default if any amount of whitespace), but can be a regex. Very handy even just for things where one column is separated by whitespace, but you also want to extract something delimited by ":" for example. I use awk too much, but only a small percentage of what it can do.
@chrismcgowan393814 сағат бұрын
awk is one of my favourite languages. The language itself is very 'C' like, and I always found it easy to use, except for a few weird quirks. My main use of awk is to extract data out of huge amounts of text files, and on the command line for simple tasks. I think that awk is one of the most brilliant little tools that came out of the NIX word.
@zedzpanКүн бұрын
Brings back many memories when I stumbled on awk.
@lel75317 сағат бұрын
Great video keep it up !!
@TheNovum21 сағат бұрын
Good video. this is what i like about *nix and *BSD
@GooogleGoglee19 сағат бұрын
awk deserve a playlist just for itself.
@bitti1975Күн бұрын
I hope what people will gain from this is that awk can do much more than just printing columns. I can't count how often I see a `grep ... | awk ...` pipeline. Eh? Awk can select lines by regex... Unless you need a very specific grep feature there is no reason to do that.
@paulsander5433Күн бұрын
Regretfully, awk doesn't seem to recognize extended regular expressions. That would be a legitimate use of grep before awk in a pipeline, but then it would probably be egrep rather than grep.
@dortechristiansen88621 сағат бұрын
Speed could be the reason for many grep|awk
@bitti197519 сағат бұрын
@@dortechristiansen886 'Speed' regarding 'no time to think'? Clearly you can not mean performance, since invoking two programs (and another subshell) is of course slower than just one.
@bitti197518 сағат бұрын
@@paulsander5433 I'm not sure what you mean. The original AWK (BSD/macOS) manpage says: "Regular expressions are as in egrep; see grep(1)." and GNU AWK's manpage says "Regular expressions are essentially the same as those in egrep(1).", so the most common AWK versions in use should support the same regexes as egrep.
@dortechristiansen88614 сағат бұрын
If grep is many times faster to regex it could be faster
@ps-ri2qkКүн бұрын
Thanks for the Aho Weinberger Kernighan formatting/scripting tool video. I remember/forget this from the O'reilly books in the 90's. While trying to follow along on YT and pausing the video the lower area has this red line with controls, obfuscating the bottom 1/2" or so. Would you consider formatting it so the commands are well above the bottom area of the video? Then when it's paused it would be easily readable to look at in detail. Thanks again!
@kees3125Күн бұрын
While paused, tap/click on empty area and controls are hidden!
@anon_y_mousse23 сағат бұрын
I use awk in my .bashrc to filter various commands. For example, I print only the relevant drives from df's output and I make sure the header still prints out. Since I use a pattern for the type of drives to display, it even works with flash drives and external hard drives too.
@LitheInLitotes20 сағат бұрын
Awk makes powershell's objects really desirable by comparison... Too bad ms is evil
@joeteejoeteeКүн бұрын
This very helpful for ole' rusty linux hobbiests like me. Liked and subscribed for sure. Thanks!
@AdrianBoykoКүн бұрын
I had a CompSci professor in the early 1990s who called AWK “The Queen of Programming Languages” 😵💫
@ohdude6643Күн бұрын
He was not wrong.
@sarundayo8 сағат бұрын
What's the difference between AWK and GREP?
@Stephen-wc8fn8 сағат бұрын
This brings to mind my biggest disappointment: Unix should have used tabs for column separation rather than spaces. A Unix tool chain built on tab and nl would have made text parsing so much easier.
@schlollepop21 сағат бұрын
Ah, the only write-only language ever invented. At some point, I gave up debugging awk scripts and just rewrote them from scratch if they did not work. The word “awkward” is derived from that language, right? 😉
@andreyv116Күн бұрын
Awk is quirky but it sucks less than doing non trivial things with sed
@EkShunya3 күн бұрын
why not talk abt perl as well
@TheExhaustedProgrammer2 күн бұрын
I'll add it to the list
@trueriver1950Күн бұрын
awk is well suited to short one-off scripting in a pipeline Anything more complicated then yes: I would use Perl.
@ivanheffner2587Күн бұрын
I think this video showed up in my feed because earlier today I said: What do you get when you implement sed and awk in ksh? Perl 4. IIRC Larry Wall wrote Perl to combine multiple tools into one scripting language without so many pipelines. It made a pretty good programming language for a while, too.
@sssxxxtttКүн бұрын
I skipped awk, except for being able to read it. If I can’t do it in sed I go to perl. Admittedly heavier but with hw of today…
@andreyv116Күн бұрын
Awk is more minimal than Perl but if your things are complex enough then Perl is more maintainable
@PaulHewsonPhDКүн бұрын
I still struggle to use awk where appropriate hoping one day I may get fluent. But one thing always beats me, csv files that have commas embedded within a quoted text field. Nice video!
@danblanks3190Күн бұрын
It was commands like awk, clearly designed by committees of committees packed with a dizzying array of options, that make me so glad that I never have to work on a Linux system ever again for the rest of my life.
@anon_y_mousse23 сағат бұрын
Point to where on the doll Linux touched you. Remember, therapy only works if you allow it to work.
@soppaism23 сағат бұрын
I think it's the exact opposite of that. If you want to get as much done as possible while memorizing as little weird syntax as possible, awk is one of the best choices out there.
@stevevandevender831922 сағат бұрын
As pointed out in the video, awk was developed as part of the original UNIX in the 1970s when Linus Torvalds was still a toddler, and it's named after its original authors, Aho (co-author of a famous textbook "Principles of Compiler Design"), Weinberger, and Kernighan (who co-wrote "The C Programming Langugage" with Dennis Ritche and "The UNIX Programming Environment" with Rob Pike). So a committee of three, perhaps?
@danblanks319015 сағат бұрын
@@anon_y_mousse 😂😂😂
@PiotrRzeszów-c9xКүн бұрын
maybe just use copilot + python?
@tracyrreedКүн бұрын
awk is a lot faster to whip up a one liner to do something like parse a process list vs opening a pipe from ps in Python and parsing that. Awk is everywhere and although python is pretty common these days you can't count on it being installed everywhere. Particularly inside busybox or a container. Plus, MS stinks. I don't want to put on those handcuffs.
@inertia_daggerКүн бұрын
no
@wrathofainzКүн бұрын
Ew, Microsoft
@paulsander5433Күн бұрын
@@tracyrreed The other problem with Python is that it's not source code compatible with Python. Every few minor releases, they change or remove a feature that breaks existing scripts. They didn't learn from Perl's early mistakes. Ruby has the same problem. Awk, sed, bash, ksh, and other languages generally don't have that problem.
@ivanheffner258721 сағат бұрын
@@PiotrRzeszów-c9x Or you could try being a decent programmer with an actual understanding of the tools you use rather than being next generation of skript kiddie reliant on GIGO LLM to do your job.