Demystifying "find" and "find -exec" ...Lil' Linux Lesson!

Sdílet
Vložit
  • čas přidán 12. 06. 2024
  • Has the internet told you Linux' "find" command is too scary to use? Well, they're wrong. Linux' "find" command - also found in lots of other *NIX systems - is a critical tool to learn.
    In today's Lil' Linux Lesson, I'll be demystifying the "find" command, and covering how it works with the "-exec" option, and the superpower differences between using "+" and using ";", which I promise will make your life easier as a sysadmin, Linux user, or just any nerd who likes to play with the terminal.
    Lastly, this video wouldn't be possible without my monthly sustaining supporters on Patreon and Ko-Fi. Members get a bunch of cool perks- if my unsponsored videos help you, I appreciate your consideration!
    / veronicaexplains
    ko-fi.com/VeronicaExplains
    0:00 I say "greetings" and tell you why the find command is important
    1:24 Basic use of find, both GNU and BSD variants!
    2:46 Performing magic in the terminal with find -exec
    4:56 Some other parameters for find: -iname, -type, -user, -group, -perm, -size
    6:53 Why does find -exec end with a plus?
    #linux #homelab #terminal
  • Věda a technologie

Komentáře • 587

  • @VeronicaExplains
    @VeronicaExplains  Před 23 dny +42

    Some of you commenters are pointing out, accurately, that `grep` can recursively search files on its own, without `find`. Of course it can! But remember, grepping was just the example I was using to illustrate `-exec`. Your options between `-exec` and `{} +` are practically limitless.
    Also, to those of you about to voice your displeasure with "needing the terminal to find lost files", your assignment is this word problem: "Susie has a VPS running a web server, and her server daemon has crashed due to a malformed configuration file. How can Susie identify and resolve the problem using only GUI tools and no terminal commands?"

  • @greendblink182
    @greendblink182 Před 26 dny +109

    Keeping up with the Commodore would be a reality show I would actually watch

  • @chadcordero1618
    @chadcordero1618 Před 26 dny +122

    In my 30 years as a sysadmin, I've never heard of the +. I've always used the \; when using -exec. Thanks.

    • @Lordie
      @Lordie Před 26 dny +11

      37 years for me. I can't wait to soup up my automation scripts with + lol

    • @guss77
      @guss77 Před 26 dny +9

      Only 28 years here, and I also just learned about + from Veronica. ✌️

    • @FishKungfu
      @FishKungfu Před 26 dny +5

      Only 25 years here, and I always used \; too. I'll be trying the + now. Thanks, Veronica!

    • @knucklecorn
      @knucklecorn Před 25 dny +2

      hah, wait until you hear about -execdir

    • @KeithBoehler
      @KeithBoehler Před 24 dny +5

      I decided at one point to never skip an intro to a subject for reasons like this. Sometimes you just learn something new and that is awesome!

  • @robbylock1741
    @robbylock1741 Před 26 dny +146

    I'm a retired UNIX/Linux System Administrator (30+ years) and I find your content refreshing and more to the point very useful! Yeah there are newer and perhaps simpler commands, but knowing the basics is still very important. People would ask me why learn vi when there is nano for example. Because from AIX to (name your Linux distro) etc, you'll always have vi :) Thanks again for your hard work and keep keep doing what you're doing!

    • @illegalsmirf
      @illegalsmirf Před 24 dny +1

      @@occamraiser Not quite sure how to handle this, but are you aware of the fact vim has more features than nano does? Of course, if you haven't taken the time to learn vim then you won't be aware of that fact and if the pitiful nano is all you need then it's fine. But it is shite for handling text files of any non-trivial degree of length or complexity.

    • @DavidSchmitt
      @DavidSchmitt Před 24 dny +1

      Ha, I learned vi on AIX 3.2 in '97

    • @saszab
      @saszab Před 24 dny

      mc (Midnight Commander) has been around for 30 years. Why people are still using find, vi, nano and so on? I understand that there are some cases when there's no other choice (for example, to run certain command with all the found files), but they are very rare.

    • @DavidSchmitt
      @DavidSchmitt Před 24 dny +3

      @saszab mc is great for interactive use but extremely unhelpful for shell programming.

    • @saszab
      @saszab Před 24 dny

      @@DavidSchmitt Sure, but these are vary rare cases. Vast majority of the Linux users never write scripts.

  • @Andoresu96
    @Andoresu96 Před 26 dny +90

    I like the part where veronica says "its explaining time" and explains all over the place

  • @ducksauz
    @ducksauz Před 26 dny +28

    Holy Crap! 30+ years in this business and I *just* learned about '+' as an argument to find.
    How much of my life have I wasted to \; ?!
    Thanks Veronica! You're frickin' awesome!

    • @uthamal
      @uthamal Před 25 dny

      Same here, I always tended to use -print0 and pipe it to xargs -0. Thanks Veronica!

  • @jefflsmith616
    @jefflsmith616 Před 26 dny +18

    This was a real "+" for a topic. I use "find" nearly every day and did not know it has alternate endings \; Thanks.

  • @Richthofen80
    @Richthofen80 Před 26 dny +46

    It's a good day when there's a new video from Veronica!

  • @d00kieC
    @d00kieC Před 26 dny +21

    As someone who was "cool" in the mid-nineties, I appreciate the spacehog based puns.

  • @Aura_Mancer
    @Aura_Mancer Před 26 dny +6

    Thank you! Because honestly, even as a somewhat experienced Linux user, learning these types of tools is hard, because you only use it when you needed by looking at the long documentation, then you never touch it again so you forget. Then when you needed it once more, it's the same tedious process. A fun video like this is perfect to master a tool like this!

  • @zantetsu8674
    @zantetsu8674 Před 26 dny +36

    I prefer `find | xargs grep` because it executes grep one time across all the found files instead of executing a separate grep for each file as find -exec would do. find | xargs grep is often an order of magnitude faster when grepping a lot of files.
    EDIT: OK I wrote the above before I finished watching the video! And I see the the '+' form of exec does effectively the same thing. Wow I learned something new after using find daily for about 25 years. Thanks!

    • @VeronicaExplains
      @VeronicaExplains  Před 26 dny +15

      The + in my command executes once though.

    • @dingokidneys
      @dingokidneys Před 26 dny +5

      @@VeronicaExplains I also learned this trick for the first time after using xargs for years. I gotta RTFM a bit more. 😁

    • @Rudxain
      @Rudxain Před 26 dny +2

      I want to mention GNU `parallel`, which is similar to `xargs` but distributes the load across all logical cores. The only bad thing is that it requires a Perl interpreter (and many other Perl dependencies)

    • @gedeonducloitre-delavarenn8106
      @gedeonducloitre-delavarenn8106 Před 25 dny +5

      the xarg approach is an antipattern: it's broken with filenames containing quotes or newlines. The cure is to use GNU's versions with the -print0 predicate to find, and the -0 (or --null) option to xarg. But this is not portable, and is very awkward. -exec (or even -execdir) with + is the correct approach

    • @billeterk
      @billeterk Před 24 dny +1

      I believe neither ‘+’ nor xargs necessarily put all the files as arguments to the command but parcel them up with respect to MAXARGS.

  • @petermayes8764
    @petermayes8764 Před 26 dny +22

    Started using Unix on a VAX 11/780 in the '80s before you were born!! But you're never too old to learn something new! Been using "\;" since then, and only just now learned about "+"! Thank you.

  • @ftolead
    @ftolead Před 26 dny +12

    The find command can be insanely powerful. I just learned the (+) versus the (;). Thank you for that. I had always used ; and didn't know about the +

  • @paul.j.macdonald
    @paul.j.macdonald Před 24 dny +3

    Been a Linux user for 20+ years. Love your videos and how you extend your knowledge to newer users. Keep it up.

  • @UnwalledGarden
    @UnwalledGarden Před 26 dny +24

    Your no nonsense explanations are great!

  • @CurrentlyVince
    @CurrentlyVince Před 25 dny +3

    I love these videos -- if I ever have any kind of "virtual assistant" on a Linux machine, I want the voice to be Veronica Explains in 8th grade math teacher mode.

  • @MrG0CE
    @MrG0CE Před 24 dny +6

    SHE'S A LIGHT IN THE LINUX COMUNITY !
    LIKE THE GUY FROM "THE LINUX EXPERIMENT".

  • @flapjack9495
    @flapjack9495 Před 24 dny +2

    I've been a professional Linux sysadmin since the 90s and use the find command all the damn time. This intro was perfect, and it taught me something I didn't know - ending the command with a plus instead of a semicolon. That's super useful in many contexts - thanks for that!

  • @thekidneystoner6183
    @thekidneystoner6183 Před 26 dny +8

    Linux has been my development platform for work for nearly a decade, but I still watch these videos because of how fun they are. And speaking of keeping up with the Commodore, I haven't written a BASIC program in years, I realised I miss it.

    • @paulsander5433
      @paulsander5433 Před 24 dny +1

      Ah, but would you admit that on a CV? Right after knowing how to configure sendmail, without the help of m4?

  • @remi6801
    @remi6801 Před 26 dny +8

    Are you keeping up with the Commodore?
    Love your channel ! Very informative and entertaining !

    • @VeronicaExplains
      @VeronicaExplains  Před 26 dny +4

      Thank you! I have it on good authority that the Commodore is keeping up with us.

  • @andrewlankford9634
    @andrewlankford9634 Před 25 dny +2

    Never knew Gilda Radner was so into Linux. And still alive for that matter.

  • @s.i.n4985
    @s.i.n4985 Před 18 hodinami

    Wow, i actually think this is pretty cool that you are keep going through years! there is not so many youtubers that discuss linux and this nerd stuff, i believe in you!🥰😍

  • @xcalibur839
    @xcalibur839 Před 26 dny +10

    Great video, looking forward to the grep episode as well. Are you keeping up with the Commodore?

  • @DavidSchmitt
    @DavidSchmitt Před 24 dny +1

    Been using find for 25 years and still learned something new (+). Thanks!

  • @Irenethemeanbean
    @Irenethemeanbean Před 26 dny +2

    Thank you, Veronica! I’m finally taking my first steps into Linux and you’re helping me ‘find’ things along the way!

  • @mausmalone
    @mausmalone Před 26 dny +1

    'cause the Commodore is keeping up with you! Loved how simple this was, and especially the explanation of the exec parameter termination and curly braces. I've seen so many "here's how you use find to ..." tutorials and never understood what was going on with those.

  • @user-hc6uo5fp8n
    @user-hc6uo5fp8n Před 26 dny +2

    Thank you for doing these Lil' Linux Lesson and concentrating on the commands that builtin rather than the newer that are not always in the repo's.

  • @FP_95
    @FP_95 Před 6 dny

    Your teaching skills are GOD tier. Thanks for all your hard work!

  • @zrodger2296
    @zrodger2296 Před 26 dny +2

    I need to try out a few examples tomorrow on my system, it's been awhile since I used this sequence of commands. I always used to use find then xargs then grep. Great timely video!

  • @joseoncrack
    @joseoncrack Před 26 dny +1

    Useful and to the point. No annoying sponsorship. 👍

  • @user-vr2rq5hl6l
    @user-vr2rq5hl6l Před 26 dny +1

    Using “find” with -exec is so powerful! I’ve been using it since I first discovered it in a Unix manual in 1985. Whew!

  • @kevinrineer5356
    @kevinrineer5356 Před 26 dny +3

    thanks for the different between the + and \; !
    I know I had read that at one point, but forgot the difference a long while ago.

  • @octopusonfire100
    @octopusonfire100 Před 26 dny +5

    The moment I learnt how to use find, I felt like I had unlocked a superpower.

  • @dunkinDoge
    @dunkinDoge Před 21 dnem +1

    saw the video couple of days ago, ended up needing this today.
    You saved me a loooooot of time and troubles. you're awesome

  • @tuxthedev3470
    @tuxthedev3470 Před 25 dny

    This video format is amazing!

  • @bargainbincatgirl6698
    @bargainbincatgirl6698 Před 26 dny +1

    This is what I need to start my weekend, a quick explanation of how to use a command tool older than me....
    And I'm 40 years old.

  • @zach9799
    @zach9799 Před 26 dny +1

    I love your videos. So information-dense! Great point about using fundamental built-in commands on systems that you can't install unnecessary packages on.

  • @ouilogique
    @ouilogique Před 24 dny

    👍 for the “+” tip.
    If you need absolute paths use "`pwd`" instead of .
    And if you want one line per result use “find” a second time instead of “echo”
    find "`pwd`" -type f -exec find {} +

  • @dewildtvanreenen4358
    @dewildtvanreenen4358 Před 7 dny

    This was quite serendipitous two days after watching your video I needed to delete a bunch of svg’s and I would not have thought of find if not for your video

  • @kellybmackenzie
    @kellybmackenzie Před 26 dny

    I adore your content so much! I always learn so much with your videos, thanks a lot!

  • @matthewrease2376
    @matthewrease2376 Před 26 dny +7

    "Have you played Atari today!"
    (No commodore because I'm a rebel. "

    • @saszab
      @saszab Před 24 dny

      ZX Spectrum rulez!

  • @GoWithAndy-cp8tz
    @GoWithAndy-cp8tz Před 22 dny

    Hi Veronica. I'm amazed by your passion for computers! I really appreciate your videos. Cheers!

  • @guilherme1556
    @guilherme1556 Před 21 dnem

    Awesome video Veronica, I loved this type of video with a specific linux topic!

    • @VeronicaExplains
      @VeronicaExplains  Před 13 dny

      Thank you for the support! More videos like this are on the way!

  • @jay_wright_thats_right

    I love your damn videos. I can't wait to see where this channel is at this time, next year. No pressure, though!

  • @klemmr3233
    @klemmr3233 Před 13 dny

    Our late cat loved my C64. He was always a keyboard walker, but this was his favourite. I'm keeping up with my Commodore now, as it's safe to plug it in again.

  • @ViewtifulSam
    @ViewtifulSam Před 23 dny

    As to the point @ around 1:11, I'm really glad you made a video about find because the simpler stuff such as fd doesn't require much explanation and the deep uses of find seem really really useful!

    • @VeronicaExplains
      @VeronicaExplains  Před 23 dny +1

      As of this moment, fd is unlikely to be in your baseline distro, container, or enterprise approved tools list. Find will be though!

  • @bruck2723
    @bruck2723 Před 26 dny +5

    | column is the coolest thing i learned today.

    • @saszab
      @saszab Před 24 dny

      It's called pipe.

    • @bruck2723
      @bruck2723 Před 24 dny +1

      @@saszab | this is pipe, that i know . i didn't know you could column like that.

  • @derekr54
    @derekr54 Před 26 dny

    Great video as usual,thanks Veronica

  • @frighteningenius
    @frighteningenius Před 25 dny

    yayy new linux video!!
    edit: also, congrats on the 100k :)

  • @MichaelMossmanNZ
    @MichaelMossmanNZ Před 26 dny +1

    Thanks for another great vid! I'm keeping up with the Commodore ... the Holden Commodore automobile that is, formerly manufactured by GM Australia. Greetings from down-under =)

  • @user-ng8cx3fj5p
    @user-ng8cx3fj5p Před 2 dny

    I heard about this channel on Mastodon. I like your videos very much, thank you for your work!

  • @tomkelley4119
    @tomkelley4119 Před 26 dny +2

    This is a good series.
    Also, are you keeping up with the Commodore?

  • @donaldwilliams6821
    @donaldwilliams6821 Před 26 dny +1

    Great video Yes, there are newer and faster utils but at work I have much older Linux servers without access to them So knowing how to do it the "old fashioned " way is important. Plus if your scripts use them it's more portable to any system. You can always check for the presence of FD, etc and use "classic" FIND as a backup

  • @kumar_prabhat
    @kumar_prabhat Před 26 dny +5

    love it, keep 'em coming

  • @Getoverhere666
    @Getoverhere666 Před 26 dny +1

    Veronica, your are the miracle!

  • @alec1575
    @alec1575 Před 24 dny

    Huge thank you for this, wasn't aware of the "find" command before the video. Really love your Lil' Linux Lessons BTW. -PS Are you keeping up with the Commodore?

  • @henriquepicanco97
    @henriquepicanco97 Před 26 dny

    I never understood the find command... Until now! Thanks, Veronica!

  • @KoopstaKlicca
    @KoopstaKlicca Před 26 dny

    Very useful video, thank you!

  • @ryanlemere4212
    @ryanlemere4212 Před 24 dny

    Super awesome love the jams! Great info! Are you keeping up with the commodore?

  • @Hinipe
    @Hinipe Před 11 dny

    I find your explanations easy to follow. :)

  • @jrpsims
    @jrpsims Před 20 dny

    Nice video, and I’m happy to see people still using find.
    Be careful with quotes! The double quotes you used around *.txt will still allow the shell to expand the wildcard instead of passing it to find. You need to use single quotes, or put \ in front of the *.
    Your example passed into find a list of filenames, not the pattern *.txt

  • @ImL8
    @ImL8 Před 26 dny +4

    Thanks for another entertaining video!

  • @speakerbench
    @speakerbench Před 11 dny

    Excellent little tutorial and I look forward to the others. I've been using Linux a bit, on-and-off since 2005, and used find regularly, but consider myself a novice.

  • @neuralmodulator
    @neuralmodulator Před 26 dny +5

    Spacehog references = definite win

  • @malfunction5448
    @malfunction5448 Před 23 dny

    are you keeping up with the Commodore? Great video! I always learn some new nuance I'm not familiar with in these lil' linux lessons 😁

  • @ericpayne2846
    @ericpayne2846 Před 26 dny

    Hi Veronica! I have been subscribed and watching your videos for about a year now, and I just wanted to comment that they are very entertaining, and my favorite are the "Lil' Linux Lesson!" variety, because I have A LOT to learn and I really love it when I learn something new and useful by the time the video ends (like this one!) Thanks for making these, and I hope to see more "Lil' Linux Lesson!" videos in the near future. by the way, are you keeping up with the Commodore?

  • @PaulHeffner
    @PaulHeffner Před 24 dny

    I've been using 'find' since the early '80s but I'm too aware how even the earliest commands "evolve" over time so I had a look. This is a nice overview of the basic command (like others, I didn't know about the '+' delimiter, that was worth the watch by itself. One explanation that would help is how the predicates of find act as a left-to-right execution queue, meaning you can list the conditions and each will be tested and if it succeeds, find will move on to the next test. This allows really useful sets of tests where you can do things like "files owned by fred larger than 1gb whose name begins with 'p'. A really nice video, thanks! (Keeping up with the Commodore)

  • @mcatower
    @mcatower Před 26 dny

    Great video! Do more useful command explainers like these please ❤

  • @GeoffintheGarage
    @GeoffintheGarage Před 25 dny

    Such a useful info-dense video! I just started a network tech class with a Linux portion, so these videos are super helpful and well-timed for me. Looking forward to the grep lil' Linux lesson too. Are you keeping up with the Commodore?!

  • @alicewyan
    @alicewyan Před 26 dny

    When Veronica tells me I'm awesome it makes my day ☺
    btw, are you keeping up with the Commodore?

  • @VexisMorlock
    @VexisMorlock Před 26 dny +2

    I feel like we should mention that you shouldn't try to get to fancy with -exec; It can often lead to unwanted results. ie don't use this to rename or manipulate files on your system, but this kind of thing is fine. Also if you have not covered xargs its one of my favs.

    • @eDoc2020
      @eDoc2020 Před 22 dny

      Whenever I do potentially dangerous actions with scripting I always do a "dry run" with echo before the actual command name.

  • @nicozica
    @nicozica Před 26 dny

    Are you keeping up with the Commodore?? I understand very little of this part of the Linux world.. But your videos are always a joy to watch.. Cheers Veronica!! You're as awesome as Linux 😀🤗

  • @TechnologyJunkie
    @TechnologyJunkie Před 26 dny +1

    Hard to believe it has been 30 years since the demise of C=. My A-3000 still rocks, and my C= 128 is still great.

  • @pjcpspn670
    @pjcpspn670 Před 26 dny +1

    Love the humor, do the thing that makes the thing tell you when I publish the thing hahaha, Nice Vid.

  • @wingflanagan
    @wingflanagan Před 26 dny

    Veronica, you are my spirit animal!

  • @brendanbeasley6262
    @brendanbeasley6262 Před 26 dny

    Another interesting and informative video. Are you keeping up with the Commodore?

  • @Compact-Disc_700mb
    @Compact-Disc_700mb Před 26 dny

    Thanks this is very helpful! I like these Lil' Linux Lessons. Also are you keeping up with the commodore?

  • @gyorgybereg6916
    @gyorgybereg6916 Před 26 dny

    Keep up the commodore and the vids!

  • @MrAnish310
    @MrAnish310 Před 13 dny

    Great explanation in 8 minutes especially exec +

    • @VeronicaExplains
      @VeronicaExplains  Před 11 dny

      Thanks! That's my goal with these, trying to keep them under 10 minutes and still thorough.

  • @notgeekenough5670
    @notgeekenough5670 Před 26 dny

    Awesome explanation! thank u so much! and....Are you keeping up with the Commodore??!

  • @PhilipStorry
    @PhilipStorry Před 25 dny

    Thanks! A very nice summary of an essential command.
    I'm hoping that in a follow up you can find a way to cover options like -mmin and -mtime as I find those very useful when looking for recent changes. Given that like many others I didn't know about the + terminator for -exec I wonder if I'm missing some magic in date and time handling too?
    Also, are you keeping up with the Commodore? He's pretty quick for his age, but doesn't get to sea very often these days... ☺

  • @michaelwright2986
    @michaelwright2986 Před 9 dny

    I feel I may be going back to the command line, thanks to this sort of thing. Also, at 1:30 I liked the undertaking to treat comments with all the patience of a substitute 8th grad maths teacher. That should be an ANSI standard.

  • @jameskemman5892
    @jameskemman5892 Před 26 dny +4

    going straight on my to watch list :)

  • @sansmojo
    @sansmojo Před 20 dny

    find is one of my most used commands. Great video.

  • @thatflutterdev
    @thatflutterdev Před 26 dny

    Thanks for making this useful video, I didn't know the find command existed until now

  • @ya64
    @ya64 Před 19 dny

    Didn't know about the file size option. Very useful!

  • @mattnik
    @mattnik Před 23 dny

    Thanks so much for posting this! 🙂

  • @sabret00the
    @sabret00the Před 3 dny

    Just what I needed. Thank you so much.
    Are you keeping up with the Commodore.

  • @ringo8410
    @ringo8410 Před 25 dny

    Brilliant! Thank you for the lesson. I'm trying to keep my Music directory tidy, and using the find command you provided helped me to find .MP3 files (which work, but the perfectionist in me doesn't like the all caps file extension).
    Are you keeping up with the Commodore?

  • @henrique610
    @henrique610 Před 26 dny

    Great video!
    Are you keeping up with the Commodore?

  • @MeaTLoTioN
    @MeaTLoTioN Před 26 dny +1

    + vs \; I didn't know, thank you for a great little video, Veronica. I was looking to see if there was CP/M for the c64 the other day, are you keeping up with the commodore?

  • @octaviolopez9966
    @octaviolopez9966 Před 26 dny

    As a linux user my self, i welcome more ways to do tasks in linux wether it is with a gui or cli, the same for browsers, i don't mind using chromium or opera, firefox for websites, TRULLY NICE WORK, CHEERS FROM TIJUANA MEXICO!

  • @brianhonaker
    @brianhonaker Před 26 dny

    I absolutely adore your content. As a former *nix admin myself, I really appreciate the perspective. Your teaching style is amazing. Are you keeping up with the Commodore?

  • @careymcmanus
    @careymcmanus Před 26 dny

    Recent Linux convert that"s keeping up with the commodore. Finding these videos super helpful for making my transition easier

  • @andrukthegreat
    @andrukthegreat Před 19 dny

    Did anyone notice the directory in which the script for this video was in, is spelled "Scirpts" good you didn 't look for the Scripts Directory. / :) . You're Awesome Veronica!

  • @ademirgabardo1913
    @ademirgabardo1913 Před 22 dny

    Very useful video, love it.

  • @BryonLape
    @BryonLape Před 6 dny

    I've been using find like this for nearly 30 years. I remember when -print was required to see the filename. I didn't know it was mystery.

  • @Channel7Tonight
    @Channel7Tonight Před 26 dny

    Great video and very handy information I'll actually put to use. And Hey, are you keeping up with the Commodore?

  • @hazajc10
    @hazajc10 Před 26 dny

    Are you keeping up with the Commodore?! Great stuff, thanks very much!

  • @jamescoulter9659
    @jamescoulter9659 Před 25 dny

    Brilliant using find to find space hogs! (In the meantime, you can also find space hogs on The Muppet Show ; )