Why Use CAT Or GREP When You Can AWK?

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 326

  • @maximilian200057
    @maximilian200057 5 лет назад +193

    Just one day after Luke Smith's video.
    ruclips.net/video/82NBMvx6vFY/видео.html

    • @eritert
      @eritert 5 лет назад +31

      Things are heating up. Next: Why awk sucks

    • @90hijacked
      @90hijacked 5 лет назад +10

      Only SIX YEARS after Conner McDaniel's awesome SED series >:P

    • @mikewayland2576
      @mikewayland2576 5 лет назад +16

      @@eritert Next on chris titus... Why Awk is the Devil and Why So Many No Longer Use It :P

    • @agenttank
      @agenttank 5 лет назад +6

      who's the noob now? very awkward
      ;)

    • @bendover4728
      @bendover4728 5 лет назад +4

      @@eritert Why awk is bloated.

  • @OliNorwell
    @OliNorwell 5 лет назад +175

    2:54 - why bother with cat when you can awk and make the command 8-10 characters longer? I get that awk is an interesting program, but this is absurd. Come on DT, these videos are great but this is silly.

    • @bendover4728
      @bendover4728 5 лет назад +7

      He would use "sed" instead..

    • @nobytes2
      @nobytes2 4 года назад +12

      Yeah people don't use akw because a lot longer commands. Even the first users of unix like Brian still use cat, is perfectly fine. Also people use grep because is shorter. So cat and grep are the pure essence of Linux programs in the 70s be great at one thing. Awk has its purpose but it isn't to replace grep.

    • @nobytes2
      @nobytes2 4 года назад +7

      Here's a video of Brian the creator of AWK which says grep is his favorite command lmao ruclips.net/video/O9upVbGSBFo/видео.html

    • @ArdieMejia83
      @ArdieMejia83 3 года назад

      Couldnt disagree more.

    • @manuarteteco6153
      @manuarteteco6153 3 года назад

      @@ArdieMejia83 care to elaborate? Why would you still use awk when cat is way shorter and easier to type?

  • @dkosmari
    @dkosmari 5 лет назад +125

    My suggestion is to not waste time showing how a tool can awkwardly emulate another, but what it can do better. Splitting fields is one of the most common uses for awk.

    • @_yuri
      @_yuri 5 лет назад +21

      you mean awk wardly dab

    • @__-wv1my
      @__-wv1my 5 лет назад +22

      Exactly what I was thinking. "Why use "head" when you can type out this much more verbose syntax to accomplish the same thing?" hmm

    • @humm535
      @humm535 4 года назад +3

      And splitting fields with awk is not _awk_ wardly (haha) emulating other tools? Like ... _cut_ for cutting fields?

    • @igwadaa3422
      @igwadaa3422 2 года назад +1

      Well i think what's he's highlighting here is that, maybe those tools could share more of they're functionalities in a UNIX mentality, instead of having their own ways of doing some same things. awk, sed and grep could use cat binary and have it in dependency to get text from file. It would make more sense.
      But i think that's kinda the goal of busybox

    • @discomallard69
      @discomallard69 Год назад +1

      why carry around a hamer when you can hammer things with your shoe?

  • @Trigex
    @Trigex 5 лет назад +42

    To be fair, Luke specifically was talking about piping cat into grep for standard grep uses, he never proposed it as a replacement for cat in it's whole. Interesting video though!

  • @vanderfleet-martin
    @vanderfleet-martin 4 года назад +10

    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.

  • @garysalisbury4117
    @garysalisbury4117 5 лет назад +16

    All depends on the task ... and the size of the data-set and the time allowed to do it !!

  • @mitchelvalentino1569
    @mitchelvalentino1569 5 лет назад +44

    3D terminal games have been written in Awk. It’s that powerful.

    • @DistroTube
      @DistroTube  5 лет назад +19

      Tetris games have been written in awk. True story.

    • @msdosm4nfred
      @msdosm4nfred 5 лет назад +1

      @@DistroTube I like Tetris, since it was released in europe, because I'm born in the former GDR.

    • @urugulu1656
      @urugulu1656 4 года назад +3

      @@msdosm4nfred are you sure this is the right channel for you? just going by the name.

    • @pineiden
      @pineiden 4 года назад

      Really? Where what?

    • @raushonmunni2633
      @raushonmunni2633 3 года назад +1

      @@urugulu1656 MS-DOS is now open source, atleast 1.25 and 2.0. So isn't it technically the best non-POSIX os now. repo link github.com/microsoft/MS-DOS

  • @softhax
    @softhax 5 лет назад +50

    DistroTube vs Luke Smith : Civil War 😂😂

    • @bendover4728
      @bendover4728 5 лет назад +4

      Than-O.S. is coming! LoL

    • @meyimagalot9497
      @meyimagalot9497 5 лет назад +3

      No it's not. Unaboomer while immensely popular, doesnt rely on YT - he is a community builder (without probably realizing it) around i3, as he gets real life problems and shows the solutions. He's a freaking eye opener. He's not a news outlet and doesnt search for topic to cover - he discover something useful, teaches himself, improving a toolkit and shares with us.
      He shows you realtime what you can do with it from the point of view of regular (yeah, right...) staff of the university of Arizona (or in whichever hole is he know).
      Picking up on him without understanding his point (which is 20-30%% performance boost, 6 minutes instead of 9 for longer scripts) is childish and as much pathetic as calling him "another creator"

  • @BrenoSilveira94
    @BrenoSilveira94 4 года назад +7

    "Why use awk and sed if you can use Perl?"
    Just kidding, Perl is awesome.

    • @alexxx4434
      @alexxx4434 4 года назад

      Why use Perl when you can use Node.js?

    • @BrenoSilveira94
      @BrenoSilveira94 4 года назад

      @@alexxx4434 Because js it is a soydev language.

    • @alexxx4434
      @alexxx4434 4 года назад +1

      You though I was serious?

    • @BrenoSilveira94
      @BrenoSilveira94 4 года назад

      @@alexxx4434 Yes, sorry. I wooshed my self.

  • @bfrd9k
    @bfrd9k 5 лет назад +3

    Not piping from cat into grep makes sense. Using awk instead of quicker alternatives does not. grep, head, tail, and sed, are shorter and easier to type and give the same results. I bet they complete quicker as well.

  • @mitchelvalentino1569
    @mitchelvalentino1569 5 лет назад +21

    This video is spot on. Awk is seriously underutilized. One of my favorite commands.

    • @meyimagalot9497
      @meyimagalot9497 5 лет назад +11

      If you use awk for this, you shouldnt be allowed anywhere near scripting in any production environment :D

    • @gappergob6169
      @gappergob6169 5 лет назад +4

      @@meyimagalot9497 lol

    • @humm535
      @humm535 4 года назад +6

      awk is underutilized, _as a scripting language_ .
      It’s not very useful as a command, but as a scripting language for all sorts of text manipulation. Other stuff often done using awk as a command have their own commands (cutting fields with cut, _grepping eith grep_, replacing characters with tr, simple stream operations with sed, ...). awk is a scripting language!

    • @mitchelvalentino1569
      @mitchelvalentino1569 4 года назад +3

      Humm semantics and pedantics, eh? I enter the awk command and use the awk scripting language daily :)

    • @humm535
      @humm535 4 года назад +1

      @@mitchelvalentino1569 Pff. awk is for longer scripts (although not getting _too_ long ... usally ~50 loc.)

  • @0x007A
    @0x007A 4 года назад +10

    For beginners 'bc', 'cat', 'curl', 'head', 'grep', 'sed', 'tail', 'wc', and 'wget' are easier to learn for text retrieval and processing; the subprocess operator $() comes in handy too. In contrast, 'awk' is a text-processing utility with a built-in programming language. Those 5 utilities plus 'gnuplot' are sufficient for data analysis and much of data science. If programming language constructs such as variables, loops, and user-defined functions are needed, a standard *nix shell like 'bash' provides these features. By the way, I use all of these utilities and sometimes only the full capabilities of ''awk' on a daily basis to perform all stages of the data science workflow, including machine learning. Whether I choose to go awk-less depends on the project. Okay, I am sadistic. By the way, I use Python and R too but when introducing data analysis or the stages of the data science workflow up to exploratory data analysis. The 'bc', 'cat', 'curl', 'head', 'grep', 'sed', 'tail', 'wc', and 'wget' utilities allow for an interactive, step-wise refinement approach known as REPL without the cognitive overhead of programming language constructs.

  • @dvancamp
    @dvancamp 4 года назад +4

    Why use grep when you can just print the file out on a dot matrix printer and use white-out on all the lines you don’t want to see?

  • @marvinjohnson6717
    @marvinjohnson6717 4 года назад +4

    The cat replacement can be shortened to awk 1 new.sh. I do this instead of cat when I think I will want to perform an action on the file using awk after I view the contents. Now I can recall the last command and simply replace the 1 with the AWK program.

  • @ChrisTitusTech
    @ChrisTitusTech 5 лет назад +2

    *grabs popcorn* I am enjoying seeing Luke and DT go back and forth with these commands. It's like watching an awesome game of chess.

  • @strielnikovmaxim8923
    @strielnikovmaxim8923 5 лет назад +8

    Also great way to view firtst few lines using awk.
    awk ''FNR

  • @AnzanHoshinRoshi
    @AnzanHoshinRoshi 5 лет назад +18

    Thank you, Derek. "Bloat" is bloat. Use "blo" instead.

    • @unfa00
      @unfa00 4 года назад +2

      Gnu/Bloat

  • @bigfootisjustreallyshy
    @bigfootisjustreallyshy 5 лет назад +15

    This was actually hilarious. Thanks DT

  • @waldmatias
    @waldmatias 4 года назад +5

    Great video... but you answered yourself really. The simplest solution (or more readable) is usually the best one... so which do you prefer to use in a script?
    This: head file.sh
    Or this: awk '(NR>=0 && NR ... etc etc about 20 more characters... ' file.sh?
    Which would be more readable and maintainable while also allowing fellow programmers looking at your code to 'get it' quickly?

  • @user-ic7cj8lq9z
    @user-ic7cj8lq9z 5 лет назад +4

    Yea I think I recall seing this video recently of some boomer talking about using sed instead of cat.

  • @fanshaw
    @fanshaw 9 месяцев назад

    The reason we use cat at the beginning is that it moves the file being referenced to the start of the line before any processing commands. Otherwise you've got grep followed by a random pattern match, then the file you're processing, often followed by a long sequence of other things. It's easier to read and conceptualise when you have "take file X | search for content y | ..." especially if you're chaining many commands together and later you have more greps or sorts and you switch the mode of their use from including a filename to taking stdin. It makes the $1 stick out and easy to understand rather than burying it somewhere down the commandline.

  • @mkd1113
    @mkd1113 5 лет назад +73

    why say 'content creator'? Just name Luke Smith. good video apart from that dt

    • @meyimagalot9497
      @meyimagalot9497 5 лет назад +1

      YOu know, not to shout out the competition... OMG how low-key, jealous and petty it is.... I cant help it, but to me tells a lot about the character.

    • @ariathyf144
      @ariathyf144 4 года назад +3

      Felt almost insulting tbh.
      Chill Luke is giving him ideas for new content and he's not bothered to pay respect or acknoledge a gnu user fellow.

  • @seanoh432
    @seanoh432 5 лет назад +1

    using awk it feels like im using dvorak keyboard because of those special letters, eapecially when i need to finish jobs faster, i only use awk for missing features like print. time is gold.

  • @silicondecay
    @silicondecay 3 года назад +1

    Why use awk when you can use perl

  • @Khyree_Holmes
    @Khyree_Holmes 5 лет назад +6

    "This got AWKward."

  • @TheSulross
    @TheSulross 4 года назад +1

    At some point these classic Unix tools just become verbs for what we want to do - when we just want to dump files as is, or combine several files into one, we achieve that via the verb of 'cat'. When we want to scrape things per line out of a file, we 'grep' it. If we want to scrape, filter/transform a file, we 'awk' it. Even if there were one uber tool that could do all these things, I'd have to create aliases for 'cat', 'grep', 'awk' so those verbs would still be there

  • @sasakanjuh7660
    @sasakanjuh7660 5 лет назад +2

    As for head replacement, you can simplify command to "awk '{ if(NR < 11) print; else exit }' new.sh" :)

    • @sasakanjuh7660
      @sasakanjuh7660 5 лет назад

      @@bigpod I meant simplification of command he provided as replacement for head. But, in general, it is quite simple command, there's really not much to it :)

    • @sasakanjuh7660
      @sasakanjuh7660 5 лет назад

      @@bigpod Sure it is, can't argue with that, but I think that was not a point of the video :)

  • @altaccount8749
    @altaccount8749 4 года назад +2

    Some people use TurboTax to file their taxes. I file them with AWK.

  • @tealc6218
    @tealc6218 5 лет назад +9

    Enough of the bloat you old goat.
    You don't need Cat or exfat.... a head or sed even if the font is in red.
    Don't use grep, or WEP and especially don't use zipgrep.
    In the terminal or youtube as you gawk, while you listen to DT talk
    He says all you need is AWK.
    -----Dr. Suess

  • @shushens
    @shushens 4 года назад +4

    As an awk lover, this video put a smirk on my face. But seriously, awk really shines when manipulating data in a limited number of potential sources. In real life scenarios, searching through large git/mercurial repos, where there are thousands of source files and a lot more build files, awk is not really your friend. All searching operations will be much much slower than grep. Grep will also be much slower than SilverSearcher or RipGrep, but those tools are not a part of any Gnu/Linux distribution.
    But you are absolutely on point about replacing sed with awk. Even when awk syntax looks longer, it is more meaningful and readable.

  • @adriansrfr
    @adriansrfr 2 года назад +1

    Grep is still the least cumbersome and most elegant for every day searches. The bloated commands, sed and awk, are better for more specialized cases. Awk is exceptional when it comes to tabular data.

  • @rashidxd
    @rashidxd 4 месяца назад

    For replacing head, you only need: "awk 'NR

  • @freesoftwareextremist8119
    @freesoftwareextremist8119 5 лет назад +1

    I'm using only awk right now for the Advent of Code. It can really do anything.

  • @christopheriwen8652
    @christopheriwen8652 4 года назад +1

    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!!

  • @Ultrajamz
    @Ultrajamz 5 лет назад +26

    Only way Luke can redeem himself is if he does a NixOS series

  • @dmiracle74
    @dmiracle74 5 лет назад +1

    Awk is like using a sledgehammer to drive in a nail. LoL. I will continue to use cat and grep.

  • @janschmitt
    @janschmitt 4 года назад +1

    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.

  • @davidgomez79
    @davidgomez79 5 лет назад +13

    awk is awesome, I use it to update pip installs
    pip list --outdated | awk 'NR >2 { print $1}' | xargs pip install --upgrade

    • @DistroTube
      @DistroTube  5 лет назад +3

      Nice!

    • @davidgomez79
      @davidgomez79 5 лет назад +1

      @@DistroTube forgot xargs, but, edited the post

    • @davidgomez79
      @davidgomez79 5 лет назад +4

      @Peter Andrijeczko for using awk? No, I was sharing an example for newcomers. Its aholes like you who scare people away from linux man. How in the F, am I going to look for congratulations for simple line of awk, when I've written emulators in ASM for both 6805 and 6502. Go bug someone else if you're the bored man.

    • @davidgomez79
      @davidgomez79 5 лет назад

      @Peter Andrijeczko this isn't a penis measuring contest, I'm just saying, you came off as an ahole and you know you did.
      I'm sure you're way more capable than me but honestly, years don't equate to ability. I found and exploited a security whole in nagravision cards used by popular tv providers. A loop counter was off by one and overwrote the counter itself in ram. The loop itself was decrypting memory with IDEA cipher with a key of zero for a few loops then they got over written with a constant key. I had to encrypt my payload with 2 keys and then used another command to cause a jump to the payload in ram. I've never worked with linux as an employee and I'm self taught but. People will have their strengths and weaknesses all over the place. Like I said this isn't a pecker measuring contest.

    • @davidgomez79
      @davidgomez79 5 лет назад +1

      @Peter Andrijeczko this why i wrote emulators for both the 6805 and 6502, these cards where using these same architectures depending on the rom version. for the 2nd part of the exploit I wrote code in C++ so i could brute force a set of bytes that would give me a jump to my payload since what was being overwritten in ram was psuedo-random. I need a jump to anywhere from $0080 to $00D0 in ram. but yeah im not pro or expert.. I learn as I go and when it comes to linux I'm still a beginner. Hell I stick to debian or ubuntu for that very reason.

  • @johncrunk8038
    @johncrunk8038 5 лет назад +1

    I seldom use cat. Usually "less" or "more" for large files, sometimes with grep. The pipe is the Unix way.

  • @CrobsAdventures
    @CrobsAdventures 5 лет назад +4

    This video is such a flex that he is literally flexing in the thumbnail, love it!

  • @spirkinator
    @spirkinator 4 года назад +1

    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!

  • @moreirajesse
    @moreirajesse 2 года назад +1

    I didn't know the "tolower()" parameter in the awk command. I learned it with you. Thanks man. Greetings from Brazil.

  • @vitiok78
    @vitiok78 5 лет назад +5

    I think we need to include all that stuff into systemd )))

  • @AWriterWandering
    @AWriterWandering 7 месяцев назад

    The one caveat with replacing grep with awk is that it doesn’t support extended or Perl-like regex the way modern GNU grep does.

  • @rich13348
    @rich13348 4 года назад +1

    Why use head when with an extra 40 characters you can use awk to do the same thing. It took him that long to type out the command he jump cut it.

  • @ronobvious1785
    @ronobvious1785 4 года назад

    Why use cat? Well, cat is a lot easier to type out than awk '{print $0}' . 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.

  • @PetterBruland
    @PetterBruland 5 лет назад +2

    It's a tool in the toolbox. It's good to be aware of what the strength of each tool is, and use it in a meaningful way. -Capt. Obvious.

  • @ricardo_valerio
    @ricardo_valerio 3 года назад +1

    "why use a cap when you can use an umbrella on a sunny day"

  • @bitelogger
    @bitelogger 4 года назад +1

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

  • @eduardpertinez4767
    @eduardpertinez4767 4 года назад

    cat and grep and more and tail are the basis of UNIX systems. Do one thing and do it well. Pipe through the different things you are doing. For me it is easier to remember that cat echoes the file and grep gets the input and filters it in that to remember that grep has all those parameters one of witch is the filename. It sure has ANDs also, yet I use to pipe one grep to another if I am filtering on two conditions. In any case, the examples you give are longer to type and harder to remember that easy cat/grep equivalents.
    Offtopic: After 30 years of using grep for different piped tasks i discovered "grep -r 'someCodeSnippet'" that looks into a folder and shows you all files and file lines that contains a given text. That is soo usefull, I cannot believe I never used it.

  • @daephx
    @daephx 4 года назад +1

    Why would you present it like this? now awk seems cool but when your commands are far more verbose to get the same functionality and then advertising as a replacement?
    It should be advertised as an alt; depending on your use case, it could be more powerful or even slower then one of the other tools in terms of productivity.

  • @seanoh432
    @seanoh432 5 лет назад +1

    grep -v apple
    takes 2 seconds max to type letters.
    awk '!/apple/ {print }'
    takes 8 seconds minimum.
    if i use grep 1 week straight,
    awk will take a month.
    when i become 90 years old and medicare bill costs me 100k to extend just a month of life.
    awk? no thx.
    but agree it does things that grep sed cat is missing.

  • @takisharalabidis611
    @takisharalabidis611 4 года назад +6

    This was an interesting video. However, if I want the head of a file, I will type: head t.txt not the long awk command you suggested. Have you counted how many keystrokes are involved in the awk command? The awk utility is only to be used for complex operations, which other simpler utilities cannot perform. It is not a replacement for all other commands.

  • @CitiesTurnedToDust
    @CitiesTurnedToDust 4 года назад +5

    When you're working with things like live logs you *must* use cat instead of grep/awk etc to avoid locking the log files you're looking at. Otherwise now you're preventing the system from logging while you work which in some situations (tech support) is unprofessional.
    If you also need to do columnary processing, you can pipe your cat to awk.

    • @MaleSoCal
      @MaleSoCal 3 года назад

      The last statement fixed the first.

    • @nkpytelzhor
      @nkpytelzhor 2 года назад

      Could you please elaborate or hand me a reference material? How does awk lock the file?

  • @lunge1
    @lunge1 5 лет назад +14

    I see where this is going.

    • @humm535
      @humm535 4 года назад

      _Glenda’s so cuuute!_

  • @typecasto
    @typecasto 3 года назад +2

    1:40 "why bother with grep? grep is sort of a neat program, but it really only does one thing"
    have you heard of the unix philosophy?

  • @farhanaditya2647
    @farhanaditya2647 3 года назад

    It's like why use _reduce, map, forEach, filter, every, some, includes,_ where you can use _for loop_ for everything.

  • @Andrath
    @Andrath 5 лет назад +2

    Why use awk when you can use perl?

  • @Chalisque
    @Chalisque 3 года назад

    grep -P is not possible with awk; cat is such a common case it deserves its own program (imagine typing awk '{print}' file*.txt every time).
    Likewise, how does one implement grep -n port *.cc in awk?
    (I don't, for example, know how to match the start of a file, necessary to have a per file line number, if multiple files are specified on the command line -- grep -n gives you the filename and line number _in that file_, rather than the line number of all input files concatenated, and this is much more useful than what you can do with awk, before one adds the colour coded output you get from modern grep.)

    • @Chalisque
      @Chalisque 3 года назад

      Bit more gooling: I'll answer myself with a couple of examples:
      awk '/cout/ {print FILENAME ":" FNR ": " $0}' *.cpp
      awk 'BEGIN {n=0} FNR==1 {n=n+1;print "New File: " FILENAME} END { print n " files" }' *.cpp
      Sure you can do it, but it takes headscratching and more legwork for your poor overworked fingers. I'm someone who, with a specific task in mind, writes a 'scripts.sh' file defining 1-4 char abbreviated commands for the task at hand, just to minimise typing.

  • @CarloPiana
    @CarloPiana 5 лет назад +14

    Using awk for everything is surely doable, but sounds like a gimmick to my ear. Interesting, though.

    • @Clobercow1
      @Clobercow1 5 лет назад +4

      I think that's the joke. There is nothing wrong with using cat or grep if that's what you're used to doing.

  • @JD-im4wu
    @JD-im4wu 4 года назад +1

    and now for the bigger question... Y use vi when u got awk, sed, grep and the whole 9 yards or bash utils. nano ftw!

  •  5 лет назад +2

    2:54 Typing `awk '{ print $0 }' new.sh` is bloat. Just type `awk // new.sh`

    • @DistroTube
      @DistroTube  5 лет назад +1

      I may need to test this one...
      $ time awk '{print $0}' new.sh
      real 0m0.005s
      user 0m0.002s
      sys 0m0.002s
      $ time awk '//'' new.sh
      real 0m0.003s
      user 0m0.003s
      sys 0m0.000s

    •  5 лет назад +3

      @@DistroTube For full autism, make sure to time how long it takes to type each one. :-D You don't need quotes around // in this particular case.

  • @zakhoskins6404
    @zakhoskins6404 5 лет назад +1

    One less dependency............but a few extra characters to invoke. This is the simplest possible example of a tradeoff in programming I can think of.

  • @torben_rr
    @torben_rr 3 года назад +1

    me, watching videos on awk because my coworker who retired always used awk, and in the end he used awk for everything.
    so I had a really good laugh in the end :D.

  • @auntiecarol
    @auntiecarol 3 года назад +1

    Pretty soon you'll be browsing the web with awk and curl /s

  • @MrBearyMcBearface
    @MrBearyMcBearface 5 лет назад +12

    Something something "awk"ward
    Yeah I know. I couldn't think of anything clever.

  • @Baccarebel2580
    @Baccarebel2580 5 лет назад +1

    Because awk uses more system resources then grep. The reason not to use cat is to minimize the amount of memory needed to be allocated. Only calling grep is more efficient than using awk and also more efficient than evoking cat as well as grep

    •  5 лет назад +3

      Congratulations, you saved yourself 0m0.001s.

    • @Baccarebel2580
      @Baccarebel2580 5 лет назад

      Krešimir BTFO scrub, check out the benchmarks that came out today

    •  5 лет назад

      @@Baccarebel2580 If you're talking about Luke's video, then it shows that you save about 0.001s when using grep like it is intended, instead of awk, which I told you without measuring it. I guess, if you are that pressed for time, it matters, but in normal use nobody can notice the difference.
      Now, nobody is saying you should use awk for everything (DT's video is a bit tongue-in-cheek), but only that you can and that It doesn't really matter in most normal cases. If you cat into grep, no secret police will show up at your door to take you away.

  • @unfa00
    @unfa00 4 года назад +1

    "We can replace head with awk"
    7:37:
    Me: Nope

  • @aristotelispapageorgiou4627
    @aristotelispapageorgiou4627 5 лет назад +4

    awk is great for work with data tables

    • @DistroTube
      @DistroTube  5 лет назад +1

      True, that's really where it shines.

  • @f23anone82
    @f23anone82 5 лет назад +1

    Ok, since the "one content-creator" ignored this, maybe you would be interested in making a list of tutorials on core-utils with examples? I think it would be really nice

  • @LeonidBraynerMyshkin
    @LeonidBraynerMyshkin 5 лет назад +1

    grep has a builtin -r, or recursive, flag, which is very useful. These days I use "The silver searcher" though.

    • @xthebumpx
      @xthebumpx 5 лет назад

      Check out Ripgrep!

    • @LeonidBraynerMyshkin
      @LeonidBraynerMyshkin 5 лет назад +1

      @@xthebumpx I actually have! I use this vim plugin for searching (vimgrep is so slow) that uses ripgrep. But on the command line I prefer to use ag, even though rg is definitely faster.

  • @SebSenseGreen
    @SebSenseGreen 5 лет назад +2

    Did he just declare war?

  • @AkamiChannel
    @AkamiChannel 4 года назад

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

  • @soppaism
    @soppaism 2 года назад

    Everyone should probably use what works for them... I find myself using awk quite often, just because I tend to forget the options/flags for various separate commands (by the time it takes to man, I've already written the awk).

  • @TheGruselmops
    @TheGruselmops 5 лет назад +3

    It's legit to use cat to just print out a file.

    • @bendover4728
      @bendover4728 5 лет назад

      Cat is bloated. Use "

    • @TheGruselmops
      @TheGruselmops 5 лет назад

      ​@@bendover4728 No, use '>'. Files are bloated.

    • @bendover4728
      @bendover4728 5 лет назад

      @@TheGruselmops LoL! Yo can use 'sudo find / -type f -delete' to get rid of bloating..

    • @TheGruselmops
      @TheGruselmops 5 лет назад

      @@bendover4728 whahaha

  • @garysalisbury4117
    @garysalisbury4117 5 лет назад +1

    echo "When The Band goes Filing in" | awk '{print substr($1,1,1)substr($2,1,1)substr($5,1,1)}'

    • @eNNercY
      @eNNercY 4 года назад +1

      Is it „wtf“?

    • @garysalisbury4117
      @garysalisbury4117 4 года назад

      @@eNNercY Yes :)

    • @garysalisbury4117
      @garysalisbury4117 4 года назад

      @@eNNercY LOL unix / linix is cool ... but scripting is always quick and dirty ... but will be in no way fast ...
      Arguing between cat and awk is just clickbait !!

  • @AkamiChannel
    @AkamiChannel 5 лет назад +1

    awk ‘{print $0}’ file.txt was even more AWKward than cat file.txt | grep “search”

  • @mikewayland2576
    @mikewayland2576 5 лет назад

    Because grep is a lot faster to search though a file than awk. And the same story for cat. Just add the command time in front of the command to see how long it took to execute. For example.. time cat new.sh && time awk '{ print $0 }' new.sh. Loved the examples..

  • @DJ_Cthulhu
    @DJ_Cthulhu 5 лет назад +19

    BEGIN { print "Luke Smith" }
    😉

    • @90hijacked
      @90hijacked 5 лет назад +1

      sed "1 i Luke Smith"

  • @meyimagalot9497
    @meyimagalot9497 5 лет назад +2

    I think Luke has a point (performance) whereas DistroTube is looking for some topic to talk about

  • @benjaminwagner5440
    @benjaminwagner5440 4 года назад

    Of cause, why would you do 「head new.sh」 when you can just write 「awk '(NR>=0 && NR

  • @mahmoudagha4060
    @mahmoudagha4060 5 лет назад +3

    The tone of the video is not very promising (I am excited)

  • @bendover4728
    @bendover4728 5 лет назад +1

    Awk is great and is one of the commands I love the most... Only problem being I don't even know how to use it.

    • @MaleSoCal
      @MaleSoCal 3 года назад

      If you do not use awk yet consider gawk (GNU awk) or nawk (New awk). They are both more powerful.

  • @reverseila4363
    @reverseila4363 4 года назад

    Its sort of like using shovel instead of spoon imo

  • @voiceoftreason1760
    @voiceoftreason1760 5 лет назад +2

    sed 11q is not the same as head it seems. Shouldn't it be sed 10q?

  • @garysalisbury4117
    @garysalisbury4117 5 лет назад +4

    echo "cares one No" | cat | cat | awk '{ print $3, $2, $1 }'

    • @stanlo45
      @stanlo45 5 лет назад +1

      Ha ha ha.... awkward ;-)

  • @Harbonium
    @Harbonium 5 лет назад +1

    7:42
    How that did appear? What kind of sorcery you are doing?
    I shall give thee my like Mister Derek Distrotube!

    • @DistroTube
      @DistroTube  5 лет назад +2

      The magic of Kdenlive. I wonder if awk can edit video? Hmm...

  • @ggaston85
    @ggaston85 2 года назад

    Looks like a good to possible replace a lot of grep and sed uses, by when on earth would you replace cat with awk, that's working harder not smarter?

  • @wompa70
    @wompa70 4 года назад

    I hardly ever use cat. I use less most often. The files I deal with are more than just one screen long. I also hardly ever need just one or two key words.

  • @TdTSimonBE
    @TdTSimonBE 5 лет назад +10

    Head can be a lot shorter: awk 'NR

  • @iLiokardo
    @iLiokardo 5 лет назад +8

    More typing.

  • @hummird
    @hummird 5 лет назад

    Well although awk can replace cat or grep even if it's bulkier, saying that it can replace sed is quite a bit statement. I do a lot of parsing using sed quick and simple and I can't see how would you trade this to an awk experience. For splitting lines into columns it's fine though.

  • @Kralnor
    @Kralnor 4 месяца назад

    How about using the right tool for the job? Usually that's whatever requires the least code.

  • @edgar12334
    @edgar12334 5 лет назад +3

    Big brain time: trade awk for perl

  • @arcanelore168
    @arcanelore168 Год назад

    Have you ever maintain a GNU/Linux package, and which one?

  • @codingtudou
    @codingtudou 5 лет назад

    Use programs on what they are designed for. It's like drinking coffee with a bowl instead of a mug, of course you can do that, but what's the point?

  • @Foche_T._Schitt
    @Foche_T._Schitt 5 лет назад +1

    Let's say I got 5000 recovered text files in a folder.
    What do I do to remove text files containing certain text?

    • @FinaISpartan
      @FinaISpartan 5 лет назад

      Iterate through the files
      For each file, grep keyword, if output, rm file.

    • @serge5046
      @serge5046 5 лет назад

      Read these two articles and you'll find the answer: shapeshed.com/unix-xargs/
      alvinalexander.com/unix/edu/examples/find.shtml
      Cheers

    • @Foche_T._Schitt
      @Foche_T._Schitt 5 лет назад

      Okay while in the directory with the files I use the following
      grep -il "keyword" *.txt | xargs -n1 -i mv {} subdirectory/
      I decided not to remove the files just as a precaution.
      Seems to be working...

  • @fish830911
    @fish830911 5 лет назад +1

    Do all the awk commands you showed in this video are POSIX compliant script?

    • @DistroTube
      @DistroTube  5 лет назад

      I stuck with POSIX for this vid. There some non-POSIX ways of doing alot of this stuff too.

  • @gainzflex4125
    @gainzflex4125 2 года назад

    It would be really cool if you showed things awk can do that others can't. It sounds like awk is bringing a sledgehammer to hammer a small nail a lot of the time. It's less characters typically to do something with sed or grep, so when they do the job (which is often) why would you type more characters? I would only use awk when I can't do the same thing faster. Is there any performance difference between these commands?

  • @hermask815
    @hermask815 9 месяцев назад

    Imagine a carpenter making a video on using solely one specific hammer for all. You’d laugh about that.
    I wouldn’t abandon all other CLI tools.
    Besides the tool to replace them all .. wasn’t that Perl?