Why Use CAT Or GREP When You Can AWK?

  Рет қаралды 77,213

DistroTube

DistroTube

4 жыл бұрын

Enough of the bloat! You don't need to use cat, grep, head, sed, etc. All you need is AWK!
REFERENCED:
► www.gnu.org/software/gawk/man...
WANT TO SUPPORT THE CHANNEL?
💰 Patreon: / distrotube
💳 Paypal: www.paypal.com/cgi-bin/webscr...
🛍️ Amazon: amzn.to/2RotFFi
👕 Teespring: teespring.com/stores/distrotube
SOCIAL PLATFORMS:
🗨️ Mastodon: mastodon.technology/@distrotube
💬 IRC: irc://freenode #distrotube
👫 Reddit: / distrotube
DT ON THE WEB:
🕸️ Website: distrotube.com/
🌐 Gopherhole: gopher://distro.tube
📁 GitLab: gitlab.com/dwt1
FREE AND OPEN SOURCE SOFTWARE THAT I USE:
📽️ Open Broadcaster Software: obsproject.com/
🎬 Kdenlive: kdenlive.org
🎨 GIMP: www.gimp.org/
🔊 Audacity: www.audacityteam.org/
💻 VirtualBox: www.virtualbox.org/
Your support is very much appreciated. Thanks, guys!

Пікірлер: 330
@maximilian200057
@maximilian200057 4 жыл бұрын
Just one day after Luke Smith's video. kzfaq.info/get/bejne/bph-dbCn3Zzado0.html
@eritert
@eritert 4 жыл бұрын
Things are heating up. Next: Why awk sucks
@90hijacked
@90hijacked 4 жыл бұрын
Only SIX YEARS after Conner McDaniel's awesome SED series >:P
@mikewayland2576
@mikewayland2576 4 жыл бұрын
@@eritert Next on chris titus... Why Awk is the Devil and Why So Many No Longer Use It :P
@agenttank
@agenttank 4 жыл бұрын
who's the noob now? very awkward ;)
@bendover4728
@bendover4728 4 жыл бұрын
@@eritert Why awk is bloated.
@OliNorwell
@OliNorwell 4 жыл бұрын
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 4 жыл бұрын
He would use "sed" instead..
@nobytes2
@nobytes2 3 жыл бұрын
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 3 жыл бұрын
Here's a video of Brian the creator of AWK which says grep is his favorite command lmao kzfaq.info/get/bejne/hZ-lo7mTrLmmdqM.html
@ArdieMejia83
@ArdieMejia83 3 жыл бұрын
Couldnt disagree more.
@manuarteteco6153
@manuarteteco6153 2 жыл бұрын
@@ArdieMejia83 care to elaborate? Why would you still use awk when cat is way shorter and easier to type?
@dkosmari
@dkosmari 4 жыл бұрын
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 4 жыл бұрын
you mean awk wardly dab
@__-wv1my
@__-wv1my 4 жыл бұрын
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 жыл бұрын
And splitting fields with awk is not _awk_ wardly (haha) emulating other tools? Like ... _cut_ for cutting fields?
@igwadaa3422
@igwadaa3422 2 жыл бұрын
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 Жыл бұрын
why carry around a hamer when you can hammer things with your shoe?
@softhax
@softhax 4 жыл бұрын
DistroTube vs Luke Smith : Civil War 😂😂
@bendover4728
@bendover4728 4 жыл бұрын
Than-O.S. is coming! LoL
@meyimagalot9497
@meyimagalot9497 4 жыл бұрын
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"
@Trigex
@Trigex 4 жыл бұрын
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!
@mitchelvalentino1569
@mitchelvalentino1569 4 жыл бұрын
3D terminal games have been written in Awk. It’s that powerful.
@DistroTube
@DistroTube 4 жыл бұрын
Tetris games have been written in awk. True story.
@msdosm4nfred
@msdosm4nfred 4 жыл бұрын
@@DistroTube I like Tetris, since it was released in europe, because I'm born in the former GDR.
@urugulu1656
@urugulu1656 4 жыл бұрын
@@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 жыл бұрын
@@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
@BrenoSilveira94
@BrenoSilveira94 3 жыл бұрын
"Why use awk and sed if you can use Perl?" Just kidding, Perl is awesome.
@alexxx4434
@alexxx4434 3 жыл бұрын
Why use Perl when you can use Node.js?
@BrenoSilveira94
@BrenoSilveira94 3 жыл бұрын
@@alexxx4434 Because js it is a soydev language.
@alexxx4434
@alexxx4434 3 жыл бұрын
You though I was serious?
@BrenoSilveira94
@BrenoSilveira94 3 жыл бұрын
@@alexxx4434 Yes, sorry. I wooshed my self.
@vanderfleet-martin
@vanderfleet-martin 4 жыл бұрын
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.
@mitchelvalentino1569
@mitchelvalentino1569 4 жыл бұрын
This video is spot on. Awk is seriously underutilized. One of my favorite commands.
@meyimagalot9497
@meyimagalot9497 4 жыл бұрын
If you use awk for this, you shouldnt be allowed anywhere near scripting in any production environment :D
@gappergob6169
@gappergob6169 4 жыл бұрын
@@meyimagalot9497 lol
@humm535
@humm535 4 жыл бұрын
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 жыл бұрын
Humm semantics and pedantics, eh? I enter the awk command and use the awk scripting language daily :)
@humm535
@humm535 4 жыл бұрын
@@mitchelvalentino1569 Pff. awk is for longer scripts (although not getting _too_ long ... usally ~50 loc.)
@garysalisbury4117
@garysalisbury4117 4 жыл бұрын
All depends on the task ... and the size of the data-set and the time allowed to do it !!
@marvinjohnson6717
@marvinjohnson6717 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.
@dvancamp
@dvancamp 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?
@AnzanHoshinRoshi
@AnzanHoshinRoshi 4 жыл бұрын
Thank you, Derek. "Bloat" is bloat. Use "blo" instead.
@unfa00
@unfa00 4 жыл бұрын
Gnu/Bloat
@bfrd9k
@bfrd9k 4 жыл бұрын
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.
@serge5046
@serge5046 4 жыл бұрын
Of course!
@bigfootisjustreallyshy
@bigfootisjustreallyshy 4 жыл бұрын
This was actually hilarious. Thanks DT
@tealc6218
@tealc6218 4 жыл бұрын
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
@zakhoskins6404
@zakhoskins6404 4 жыл бұрын
If I ever have kids, I'm reading this to them.
@TheGruselmops
@TheGruselmops 4 жыл бұрын
beautiful
@thedudegrowsfood284
@thedudegrowsfood284 4 жыл бұрын
Wow. Just....wow.
@Khyree_Holmes
@Khyree_Holmes 4 жыл бұрын
"This got AWKward."
@altaccount8749
@altaccount8749 3 жыл бұрын
Some people use TurboTax to file their taxes. I file them with AWK.
@strielnikovmaxim8923
@strielnikovmaxim8923 4 жыл бұрын
Also great way to view firtst few lines using awk. awk ''FNR
@waldmatias
@waldmatias 3 жыл бұрын
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?
@mkd1113
@mkd1113 4 жыл бұрын
why say 'content creator'? Just name Luke Smith. good video apart from that dt
@meyimagalot9497
@meyimagalot9497 4 жыл бұрын
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 жыл бұрын
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.
@typecasto
@typecasto 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?
@CrobsAdventures
@CrobsAdventures 4 жыл бұрын
This video is such a flex that he is literally flexing in the thumbnail, love it!
@user-ic7cj8lq9z
@user-ic7cj8lq9z 4 жыл бұрын
Yea I think I recall seing this video recently of some boomer talking about using sed instead of cat.
@kungfumachinist
@kungfumachinist 4 жыл бұрын
Blargh! Captain Pedantic here... it's not "case insensitive" it's "case indifferent". It's the same difference as "uninterested" and "disinterested".
@shushens
@shushens 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.
@davidgomez79
@davidgomez79 4 жыл бұрын
awk is awesome, I use it to update pip installs pip list --outdated | awk 'NR >2 { print $1}' | xargs pip install --upgrade
@DistroTube
@DistroTube 4 жыл бұрын
Nice!
@davidgomez79
@davidgomez79 4 жыл бұрын
@@DistroTube forgot xargs, but, edited the post
@davidgomez79
@davidgomez79 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 4 жыл бұрын
@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 4 жыл бұрын
@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.
@TheAldun
@TheAldun 4 жыл бұрын
How would you do to substitute "grep -A" or "grep -B" with awk? cause that something I use a lot in my daily life when I'm extracting data from one particular kind of files I have. Is there any way to do it with awk or any different and more efficient wat than "grep -A/-B"? Thanks!
@Ultrajamz
@Ultrajamz 4 жыл бұрын
Only way Luke can redeem himself is if he does a NixOS series
@rodrigosouto9502
@rodrigosouto9502 4 жыл бұрын
I know what you are doing there! Lol
@0x007A
@0x007A 4 жыл бұрын
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.
@dmiracle74
@dmiracle74 4 жыл бұрын
Awk is like using a sledgehammer to drive in a nail. LoL. I will continue to use cat and grep.
@ricardo_valerio
@ricardo_valerio 3 жыл бұрын
"why use a cap when you can use an umbrella on a sunny day"
@vitiok78
@vitiok78 4 жыл бұрын
I think we need to include all that stuff into systemd )))
@rich13348
@rich13348 4 жыл бұрын
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.
@takisharalabidis611
@takisharalabidis611 3 жыл бұрын
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.
@lunge1
@lunge1 4 жыл бұрын
I see where this is going.
@humm535
@humm535 4 жыл бұрын
_Glenda’s so cuuute!_
@eyupyorulmaz3410
@eyupyorulmaz3410 4 жыл бұрын
I use awk a lot in my scripts. But one thing I wanna do is for example printing from the first column to the end of line. It is very basic thing but I couldn't find the syntax for it. Can you guys help me out?
@bendover4728
@bendover4728 4 жыл бұрын
Use cut instead... $ cut -d' ' -f2- file.txt
@fanshaw
@fanshaw 5 ай бұрын
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.
@pascal7947
@pascal7947 4 жыл бұрын
@DistroTube I was wondering, did you manage to customize stumpwm to the point you could use it or did you lose interest?
@DistroTube
@DistroTube 4 жыл бұрын
I haven't logged into stumpwm in awhile. I may get back into it at some point. Was too damn frustrating to deal with right now.
@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?
@mumk
@mumk 5 ай бұрын
Thanks and learned a lot
@DJ_Cthulhu
@DJ_Cthulhu 4 жыл бұрын
BEGIN { print "Luke Smith" } 😉
@90hijacked
@90hijacked 4 жыл бұрын
sed "1 i Luke Smith"
@arcanelore168
@arcanelore168 Жыл бұрын
Have you ever maintain a GNU/Linux package, and which one?
@CarloPiana
@CarloPiana 4 жыл бұрын
Using awk for everything is surely doable, but sounds like a gimmick to my ear. Interesting, though.
@Clobercow1
@Clobercow1 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.
@garysalisbury4117
@garysalisbury4117 4 жыл бұрын
echo "When The Band goes Filing in" | awk '{print substr($1,1,1)substr($2,1,1)substr($5,1,1)}'
@eNNercY
@eNNercY 4 жыл бұрын
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 !!
@fish830911
@fish830911 4 жыл бұрын
Do all the awk commands you showed in this video are POSIX compliant script?
@DistroTube
@DistroTube 4 жыл бұрын
I stuck with POSIX for this vid. There some non-POSIX ways of doing alot of this stuff too.
@spirkinator
@spirkinator 4 жыл бұрын
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!
@TheSulross
@TheSulross 3 жыл бұрын
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
@seanoh432
@seanoh432 4 жыл бұрын
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.
@bitelogger
@bitelogger 4 жыл бұрын
Master this is reveling to me now I'll use AWK for my log and Metadata work.
@Andrath
@Andrath 4 жыл бұрын
Why use awk when you can use perl?
@TdTSimonBE
@TdTSimonBE 4 жыл бұрын
Head can be a lot shorter: awk 'NR
@SebSenseGreen
@SebSenseGreen 4 жыл бұрын
Did he just declare war?
@logangraham2956
@logangraham2956 4 жыл бұрын
or just write your own text parser in c/c++ XD XD XD
@moreirajesse
@moreirajesse Жыл бұрын
I didn't know the "tolower()" parameter in the awk command. I learned it with you. Thanks man. Greetings from Brazil.
@PetterBruland
@PetterBruland 4 жыл бұрын
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.
@rashidxd
@rashidxd 12 күн бұрын
For replacing head, you only need: "awk 'NR
@voiceoftreason1760
@voiceoftreason1760 4 жыл бұрын
sed 11q is not the same as head it seems. Shouldn't it be sed 10q?
@gainzflex4125
@gainzflex4125 Жыл бұрын
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?
@TheGruselmops
@TheGruselmops 4 жыл бұрын
It's legit to use cat to just print out a file.
@bendover4728
@bendover4728 4 жыл бұрын
Cat is bloated. Use "
@TheGruselmops
@TheGruselmops 4 жыл бұрын
​@@bendover4728 No, use '>'. Files are bloated.
@bendover4728
@bendover4728 4 жыл бұрын
@@TheGruselmops LoL! Yo can use 'sudo find / -type f -delete' to get rid of bloating..
@TheGruselmops
@TheGruselmops 4 жыл бұрын
@@bendover4728 whahaha
@aristotelispapageorgiou4627
@aristotelispapageorgiou4627 4 жыл бұрын
awk is great for work with data tables
@DistroTube
@DistroTube 4 жыл бұрын
True, that's really where it shines.
@hummird
@hummird 4 жыл бұрын
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.
@AWriterWandering
@AWriterWandering 3 ай бұрын
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.
@daephx
@daephx 4 жыл бұрын
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.
@linuxinside6188
@linuxinside6188 4 жыл бұрын
War begins .
@bendover4728
@bendover4728 4 жыл бұрын
100 years from now: -- granpa, how the WWIII begun? -- you'll see grandkid, all it started with this Linux videos on KZfaq..
@JD-im4wu
@JD-im4wu 4 жыл бұрын
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!
@iLiokardo
@iLiokardo 4 жыл бұрын
More typing.
@ChrisTitusTech
@ChrisTitusTech 4 жыл бұрын
*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.
@ChrisTitusTech
@ChrisTitusTech 4 жыл бұрын
sed s/Luke/DT ... *shots fired*
@sasakanjuh7660
@sasakanjuh7660 4 жыл бұрын
As for head replacement, you can simplify command to "awk '{ if(NR < 11) print; else exit }' new.sh" :)
@sasakanjuh7660
@sasakanjuh7660 4 жыл бұрын
@@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 4 жыл бұрын
@@bigpod Sure it is, can't argue with that, but I think that was not a point of the video :)
@meyimagalot9497
@meyimagalot9497 4 жыл бұрын
I think Luke has a point (performance) whereas DistroTube is looking for some topic to talk about
@seanoh432
@seanoh432 4 жыл бұрын
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.
@marcuswest4572
@marcuswest4572 Жыл бұрын
6:10 "finds every line that contains 'dir' " : $1 finds every line with 'dir' in the first item
@Foche_T._Schitt
@Foche_T._Schitt 4 жыл бұрын
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 4 жыл бұрын
Iterate through the files For each file, grep keyword, if output, rm file.
@serge5046
@serge5046 4 жыл бұрын
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 4 жыл бұрын
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...
4 жыл бұрын
2:54 Typing `awk '{ print $0 }' new.sh` is bloat. Just type `awk // new.sh`
@DistroTube
@DistroTube 4 жыл бұрын
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
4 жыл бұрын
@@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.
@adriansrfr
@adriansrfr 2 жыл бұрын
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.
@unfa00
@unfa00 4 жыл бұрын
"We can replace head with awk" 7:37: Me: Nope
@janschmitt
@janschmitt 4 жыл бұрын
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.
@Harbonium
@Harbonium 4 жыл бұрын
7:42 How that did appear? What kind of sorcery you are doing? I shall give thee my like Mister Derek Distrotube!
@DistroTube
@DistroTube 4 жыл бұрын
The magic of Kdenlive. I wonder if awk can edit video? Hmm...
@christopheriwen8652
@christopheriwen8652 4 жыл бұрын
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!!
@freesoftwareextremist8119
@freesoftwareextremist8119 4 жыл бұрын
I'm using only awk right now for the Advent of Code. It can really do anything.
@brianhansen2202
@brianhansen2202 4 жыл бұрын
I don’t know this channel, and I will never see it again...
@bendover4728
@bendover4728 4 жыл бұрын
% export HE_WHO_MUST_NOT_BE_NAMED="Luke";
@johncrunk8038
@johncrunk8038 4 жыл бұрын
I seldom use cat. Usually "less" or "more" for large files, sometimes with grep. The pipe is the Unix way.
@benjaminwagner5440
@benjaminwagner5440 4 жыл бұрын
Of cause, why would you do 「head new.sh」 when you can just write 「awk '(NR>=0 && NR
@edgar12334
@edgar12334 4 жыл бұрын
Big brain time: trade awk for 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.
@auntiecarol
@auntiecarol 3 жыл бұрын
Pretty soon you'll be browsing the web with awk and curl /s
@zakhoskins6404
@zakhoskins6404 4 жыл бұрын
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.
@ryukshinigami5106
@ryukshinigami5106 4 жыл бұрын
So can we concat two files with awk?
@batchrocketproject4720
@batchrocketproject4720 Жыл бұрын
awk '//' file1 file2 # leaves original files intact, result to stdout or > to new file
@Kralnor
@Kralnor 5 күн бұрын
How about using the right tool for the job? Usually that's whatever requires the least code.
@AkamiChannel
@AkamiChannel 4 жыл бұрын
If you have a long chain of commands, it may assist in readability to cat file | at the beginning.
@Zellonous
@Zellonous 4 жыл бұрын
Something something "awk"ward Yeah I know. I couldn't think of anything clever.
@DanielCardin_ATX
@DanielCardin_ATX 4 жыл бұрын
Oh, it's on now...
@PestisNonSapien_GMO_exHuman
@PestisNonSapien_GMO_exHuman 4 жыл бұрын
Why use awk when you can perl or python?
@PestisNonSapien_GMO_exHuman
@PestisNonSapien_GMO_exHuman 4 жыл бұрын
Sorry, I forgot that the theme was bloat. So why use awk when you can use emacs?
@neta540
@neta540 4 жыл бұрын
Laughs in busybox
@AkamiChannel
@AkamiChannel 4 жыл бұрын
awk ‘{print $0}’ file.txt was even more AWKward than cat file.txt | grep “search”
@silicondecay
@silicondecay 3 жыл бұрын
Why use awk when you can use perl
@PenguinRevolution
@PenguinRevolution 4 жыл бұрын
I don't care what I use, as long as I can get the job done ;)
@ranjitkumargouda8970
@ranjitkumargouda8970 4 жыл бұрын
Exactly 😂
@scotth8828
@scotth8828 2 жыл бұрын
"grep only does one thing" Linux Axiom "do one thing do it well" 🤔
@eduardpertinez4767
@eduardpertinez4767 3 жыл бұрын
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.
Saving Time At The Command Line
13:49
DistroTube
Рет қаралды 75 М.
Learning Sed Is Beneficial For Linux Users
19:27
DistroTube
Рет қаралды 82 М.
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 9 МЛН
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 10 МЛН
Sigma girl and soap bubbles by Secret Vlog
00:37
Secret Vlog
Рет қаралды 13 МЛН
EVERYONE Needs to Learn a Little Bit of AWK!
16:29
Gary Explains
Рет қаралды 396 М.
My Terminal Emulator Tier List
21:36
DistroTube
Рет қаралды 100 М.
Xargs Should Be In Your Command Line Toolbag
16:24
DistroTube
Рет қаралды 97 М.
Awk: Hack the planet['s text]! (Presentation) - 2023 Update
1:07:40
Benjamin Porter
Рет қаралды 18 М.
Learning Awk Is Essential For Linux Users
20:02
DistroTube
Рет қаралды 291 М.
Two Powerful Command Line Utilities 'cut' And 'tr'
15:18
DistroTube
Рет қаралды 32 М.
Bash Scripting - Variables, Arrays, If-Then-Else
38:52
DistroTube
Рет қаралды 46 М.
Filtering .log files, with cat, grep, cut, sort, and uniq
15:36
8 super heroic Linux commands that you probably aren't using
8:38
Engineer Man
Рет қаралды 727 М.
Marks in Vim Are A Game Changer
11:01
NeuralNine
Рет қаралды 14 М.
Telefonu Parçaladım!😱
0:16
Safak Novruz
Рет қаралды 27 МЛН
Хакер взломал компьютер с USB кабеля. Кевин Митник.
0:58
Последний Оплот Безопасности
Рет қаралды 501 М.
ОБСЛУЖИЛИ САМЫЙ ГРЯЗНЫЙ ПК
1:00
VA-PC
Рет қаралды 2,4 МЛН
Ноутбук за 20\40\60 тысяч рублей
42:36
Ремонтяш
Рет қаралды 386 М.