What is wrong with locate?
i don't know what it is
Locate is like find, except it uses a cache (so finds things faster, provided your cache is up to date)
This is me every time.
locate <thing>
Not found.
Bullshit!
sudo updatedb
locate <thing>
Not found.
Ah. You were looking for thing_name, but it was called thing-name.
How did you eventually found it?
Type the correct filename.
This is the way.
locate -i <thing>
Not found.
People like this will have to run updatedb every time, when they search for stuff.
(What's a cronjob?)
What does that do?
Ls - it lists all files in the current directory -l - It shows details like last edit. -R - It gets sorted by date. Head - it shows the ten last edited files
I use it very often myself, when I'm not sure about the file name.
Not what it implicitly advertises, unfortunately. It lists all files (ls) recursively in all subdirectories (-R), one per line with details (-l), sorted by time, newest first (-t). Only the first 10 files are shown (| head).
The problem is that the files are sorted by time per directory, and ls recursively descents into subdirectories in that order. It's not a "Depth First Search", if you're so inclined. Effectively, this shows the newest 10 files/dirs in the current directory before diving down, and if you have less files/dirs than that in your search base directory, you probably don't need this hack to begin with.
In good tradition, here's something that actually works as likely intended. find recursively lists (only) all regular files (-type f) starting in the current directory (.) and runs the ls command (-exec) to show details (-l) of each file passed as arguments ({} +), including a specific, sortable time format (--time-style). The resulting comprehensive list of all files is then sorted in reverse (-r) order, using the sixth whitespace-separated column of each line/file as the key (-k6), which just so happens to be the "sortable time format". Lastly, only the 10 most recent files are shown (| head), as before:
find . -type f -exec ls -l --time-style=+"%Y-%m-%dT%T" {} + | sort -r -k6 | head
Running this is a great way to start your day! It'll give you ample time to brew some coffee or tea, slip into your most comfortable programmer socks, and finish lunch by the time it scanned your 18.3 TB of furry smut to show you what you "touched" last.
It'll likely be irrelevant cache files, though, if you run it from your $HOME. Excluding directories is left as an exercise for the reader.
Let me save you a few characters: %Y-%m-%d can be shortened to %F
For visualisation's sake I also like to put a space before the %F so that the year and the file size are separated a little more, but that's more of a taste thing than anything else.
(Caveat: %F's year is explicitly four digits in some libraries, whereas %Y is always the full year. If you're planning for your code to last 8000 years you might want to consider that.)
It lists all the files. I do not get the joke. Possibly the joke is that the head command cuts to 10 characters which probably will not display the actual file name because the l command displays the file attributes. So you see just some timestamps. Many.
Ten lines, not characters
Welp, I just learned something new and useful by logging into Lemmy at 1:30 AM.
See, there's a lot of online chatter about how much sense Linux folder structures make, with everything grouped by type all over the filesystem. And then this happens.
DOS 5.1 folder structure or bust, I say. Home directories are evil, if your filename doesn't fit in 8.3 characters you're doing it wrong and if you can't find it with dir . /w it shouldn't exist.
I learned of the PARA method somewhere on Lemmy, and found it (or an adapted version) really well-suited for myself:
https://fortelabs.com/blog/para/
The short of it is to structure files in four categories:
Projects (with a definable scope and end)
Areas of responsibility (stuff that needs to be done repeatedly or constantly without any defined "end", like timesheets or budget plans)
Resources (learning material, reusable assets)
Archive (finished / abandoned projects, areas no longer relevant for you, resources you're not longer interested in)
I suck at the "abandoned project" part, because I refuse to accept when I'm not gonna keep at something any more, and sometimes have stuff lingering in my "Areas" that should long be archived. I also have some things that are kinda perpetually ongoing developments without any clear "end", although each increment of work does, so they occupy some hybrid space between Area and Project. I've put them in Projects anyway, because the point is to help me find things and making "Projects" the place to find "Things I'm working on" is easy enough.
linuxmemes
Hint: :q!
Sister communities:
Community rules (click to expand)
1. Follow the site-wide rules
- Instance-wide TOS: https://legal.lemmy.world/tos/
- Lemmy code of conduct: https://join-lemmy.org/docs/code_of_conduct.html
2. Be civil
- Understand the difference between a joke and an insult.
- Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
- Don't get baited into back-and-forth insults. We are not animals.
- Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
- Bigotry will not be tolerated.
3. Post Linux-related content
- Including Unix and BSD.
- Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of
sudoin Windows. - No porn, no politics, no trolling or ragebaiting.
- Don't come looking for advice, this is not the right community.
4. No recent reposts
- Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
5. ๐ฌ๐ง Language/ัะทัะบ/Sprache
- This is primarily an English-speaking community. ๐ฌ๐ง๐ฆ๐บ๐บ๐ธ
- Comments written in other languages are allowed.
- The substance of a post should be comprehensible for people who only speak English.
- Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
6. (NEW!) Regarding public figures
We all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations. - Keep discussions polite and free of disparagement.
- We are never in possession of all of the facts. Defamatory comments will not be tolerated.
- Discussions that get too heated will be locked and offending comments removed. ย
Please report posts and comments that break these rules!
Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.