Today's article has you using the 'find' command...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,607
Reaction score
7,354
Credits
69,966
Previous articles have used the find command but this one finally covers how to find files by name. It also repeats my usual warning about why you don't parse the output of 'ls' and we use find instead. It's a pretty easy article.


I do like me some feedback.
 


CrazedNerd

Well-Known Member
Joined
Mar 31, 2021
Messages
1,157
Reaction score
530
Credits
9,974
The find command is pretty massive and has a huge amount of features, but you covered the most important ones. The thing i like about it is that you can also search entirely by type:

Code:
find -type d

find -type f

That's a way to find every directory and file within a directory hierarchy...i'm pretty sure it has more features than both sed and awk, which says a lot:

Code:
[email protected]:~$ man sed | wc -l
301
[email protected]:~$ man find | wc -l
1685
[email protected]:~$ man awk | wc -l
1081
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,607
Reaction score
7,354
Credits
69,966
The find command is pretty massive and has a huge amount of features, but you covered the most important ones.

I've taken the 'find' command in small bites, hoping to make it more approachable. There's just so much to it that it likely overwhelms new users.

It's a bit like ffmpeg... I'd like to cover some of that command, but it sure can be involved.
 

CrazedNerd

Well-Known Member
Joined
Mar 31, 2021
Messages
1,157
Reaction score
530
Credits
9,974
I've taken the 'find' command in small bites, hoping to make it more approachable. There's just so much to it that it likely overwhelms new users.

It's a bit like ffmpeg... I'd like to cover some of that command, but it sure can be involved.
If the focus is the new users, you could explain that a directory hierarchy is the directory and all its child directories. It wasn't obvious to me at first.
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,607
Reaction score
7,354
Credits
69,966
If the focus is the new users, you could explain that a directory hierarchy is the directory and all its child directories. It wasn't obvious to me at first.

I've previously covered directories pretty heavily and aim for a specific word count. If it's too wordy, people gloss right over it. (I've monitored heat maps.) I could probably add that it's 'recursive', but that was obvious (to me) when I mentioned you can search everywhere with picking your directory's root "/".
 

CrazedNerd

Well-Known Member
Joined
Mar 31, 2021
Messages
1,157
Reaction score
530
Credits
9,974
If it's too wordy, people gloss right over it.
That's true, but you also don't want future users of the info to make up their own ideas about what they think you mean either. Letting people do that with general fiction/non is fine, but this is just too strict and rule oriented for that.

Also, another problem is that using the root directory for this purpose just isn't very practical...the home directory is better for examples, and you could easily explain directory hierarchies with simple everyday language in that context.
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,607
Reaction score
7,354
Credits
69,966
and you could easily explain directory hierarchies with simple everyday language in that context.

LOL The best you're gonna get is me mentioning that it's recursive (and maybe saying what that means). I'm definitely not gonna define the directory hierarchy and explain it in every article with directories. They'll figure it out.
 

CrazedNerd

Well-Known Member
Joined
Mar 31, 2021
Messages
1,157
Reaction score
530
Credits
9,974
LOL The best you're gonna get is me mentioning that it's recursive (and maybe saying what that means). I'm definitely not gonna define the directory hierarchy and explain it in every article with directories. They'll figure it out.
Nobody ever figures it out without experimenting so the terse description is fine i guess, i was only trying to help you...i have a lot of experience with the find command, even though i will probably never understand all the features.
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,607
Reaction score
7,354
Credits
69,966
i was only trying to help you..

Oh, I appreciate it, I just have to stay within the realm of what folks are going to read and how much time I can dedicate to each article. I'll figure out a way to work in a bit about it being recursive - but probably not until later tonight or tomorrow. I'm in the middle of a lovely blizzard and I'm going outside to play in it.
 

osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
547
Reaction score
462
Credits
5,058
CrazedNerd wrote:
problem is that using the root directory for this purpose just isn't very practical...the home directory is better for examples, and you could easily explain directory hierarchies with simple everyday language in that context.
I find this an interesting point in so far as it directs attention to useful ways of learning. I've found that creating a learning "space" to work within on the filesystem is an effective way of being able to use commands, watch their effects and do it with a lower risk of unintended consequences. For example, the creation of directory with subdirectories and files sprinkled throughout it where one can go finding, deleting, moving, renaming, chmoding, chowning, linking files etc to one's heart's content as they become familiar with what gives.
 

CrazedNerd

Well-Known Member
Joined
Mar 31, 2021
Messages
1,157
Reaction score
530
Credits
9,974
CrazedNerd wrote:

I find this an interesting point in so far as it directs attention to useful ways of learning. I've found that creating a learning "space" to work within on the filesystem is an effective way of being able to use commands, watch their effects and do it with a lower risk of unintended consequences. For example, the creation of directory with subdirectories and files sprinkled throughout it where one can go finding, deleting, moving, renaming, chmoding, chowning, linking files etc to one's heart's content as they become familiar with what gives.
I only came to that conclusion about find because I tried to make a script that would search the whole OS for a file containing a certain term in the name or in the file using the read prompt, grep, and find, and i concluded that using find in that way was cumbersome and not a great idea.
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,607
Reaction score
7,354
Credits
69,966
I've found that creating a learning "space" to work within on the filesystem is an effective way of being able to use commands, watch their effects and do it with a lower risk of unintended consequences.

Ha! I've encouraged such in prior articles and have even given people files to download and use to explore.

Those articles get read thousands of times and maybe 3 people download the example file.

(I do sometimes have folks make special directories to play with, and then tell 'em how to clean up the mess after that. I haven't done so lately as I figure about the same percentage of people are going to do that.)

I'm lucky if I can keep their attention for more than 3 minutes. They skip the intro and ignore the closure.

I did heat maps for the longest time, until just about a week ago. I used Clarity from Microsoft to track (unknown) individuals through the site. It didn't identify anyone, but let me track individuals (and trends).

Heck, want some 'proof'? Search the site for the word 'charity', which was one of my ways of testing how accurate the heat tracking was. Feel free to claim the prize. That article has been "read" many hundreds of times.

Also, the scary part (or perhaps sad, or amazing) is that getting 3 minutes of their attention puts my site above average. It's well above average.

LOL

Ah well...

I'm gonna actually go be productive in the snow (shortly, I'll check the posts first). I'd love a glass of wine, but I'll be driving a big ol' plow truck with a thousand pounds of sand in the back. Gotta be sober for this sort of stuff, but it sure is fun!
 

CrazedNerd

Well-Known Member
Joined
Mar 31, 2021
Messages
1,157
Reaction score
530
Credits
9,974
Those articles get read thousands of times and maybe 3 people download the example file.
I personally have experimented with unix commands a lot over the past year, but i have also discovered that doing that is pretty rare overall...it's quite a lonely hobby.
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Top