Find Files Created On A Specific Date

We sure do have a lot of file management articles and this is another one that will help you find files created on a specific date. This is a relatively easy task and you won’t even have to install anything new. If you want to find files created on a specific date, you might as well use this method!

Here’s a similar article.

Find Files Modified On A Specific Day

So, what is file management? To me, it’s manipulating files on your file system. It’s gathering information about the files on your file system. That’s what I mean when I say ‘file management’. I’ve covered a lot of articles with this as a subject.

Seriously… I tag articles with various terms. There are pages and pages of articles that have been tagged with file management.

Articles Tagged With File Management

Yup, that’s a lot of articles. Managing your files is something you do on a daily basis. You’re creating, editing, and moving your files around your file system. That’s file management and that’s okay!

Because this is something you do on a daily basis, even if you don’t pay attention to it, it’s something covered often. Even if you’re just browsing the internet, you’re adding files such as cached files. If you’re emailing with an email client, you have added and deleted files – if not more. File management is a pretty big thing.

Today, we’ll be using two basic commands – ls and grep. Let’s learn more!

The ls Command:

The ls command is an application that lets you list files. There are flags you can use, but it’s a basic application that, at its core, just lists files. You don’t need to install anything. You can verify that ls is available with this command:

The output should look like this:

Check the ls man page with this command:

If you do that, you’ll see that we’re on the right path if we want to find files created on a specific date. The ls command is briefly described as this:

ls – list directory contents

We’ll be using the ls command to output a list of files and we’ll then use the pipe operator to process that output with grep.

The grep Command:

The grep command is one of those commands that’s used in conjunction with another command. By itself, it’s not that useful. It is when you use grep with other commands that you realize how powerful it is.

The grep command is usually used with the | “pipe” operator. The pipe operator takes the output from one command and processes it with another application. I’ve not yet covered this in an article, nor have  I done an article about the grep command. I should do both.

Again, you won’t need to install anything. You can verify this with this command:

The output should match this:

Next, you can check the man page with this command:

grep, egrep, fgrep, rgrep – print lines that match patterns

You can see that there are options. We’ll be using just plain grep. And, as you can deduce, this is yet another process that will help us find files created on a specific date. We’ll take the output from one command and use it with the grep command. This should appear obvious shortly if you have not yet realized how we’ll be proceeding in this article.

Find Files Created On A Specific Date:

Both ls and grep are tools used in the terminal. As such, you can be sure that you’ll need an open terminal. Either open a terminal from your application menu or open a terminal by pressing CTRL + ALT + T on your keyboard. This article assumes that you don’t have year numbers in your file names, as you’ll see…

With your terminal open, we can begin to find files created on a specific date. Further, let’s stay right there in the ~/home/user directory. We’ll keep it simple.

Let’s start with this command:

That will list all your files. Now, let’s add hidden files – with the -a (all) flag with the following command:

Next up, let’s get more information from the ls command with the -l (long listing format) flag. That looks like this:

You should now see that there’s a time listed. We’re going through this just so that the example commands work. This isn’t strictly necessary, it’s just how it is being explained in this article.

If you want, you can sort that output by time. The following example command will show you the time the files were created, starting with the most recent example.

Again, that’s not strictly necessary.

Pay attention to the date section, because that’s what we’ll be using. 

More specifically, we’ll be piping the output from the ls command to the grep command. That’s done like this:

NOTE: You’ll be grepping a pattern. So, if you look carefully, the dates from 1 to 9 have two spaces! You’ll need to grep accordingly!

So, if you wanted to list articles created on the day this will be published, the command would look like this:

Notice that there are two spaces.

If you wanted to find files created on the 10th of February, your command would be different. You don’t add a 2nd space, as there is no second space in the pattern you’re looking for:

That will show you all the files (including the hidden files) that were created on the 10th of February. It does not care about the year and doesn’t show the year field. You’re simply finding files created on a specific date (ignoring the year, of course).

This is still useful.

This is also only true for files created within the past year. The ls command will happily show the date on files older than a year.

Here’s an example where the files are older than a year:

So, to find files including the year, your command now has more spaces to contend with. For this command, you would now add two spaces between the day and the year. Like so:

See the two spaces? That’s essential.

Again, don’t forget that you need two spaces when you’re working with days that are a single digit. If I wanted to find files from the 4th of November in 2022, that command would be this:

REMEMBER: The grep command is used to find patterns and will only find the specified patterns. It’s very specific! It is also very powerful when used properly.

You can do even more with this. If you want to find files older than a year and by the specific year of their creation, you could simply run a command that looks like this:

Of course, you can substitute ‘2020’ with any year you’d like and get results – so long as you have files that were created in that year.

Also, of course, that command is ONLY useful if you do not have year numbers or numbers similar to years in file names. After all, 2022 is 2022 and grep is going to find them all. That’s what grep does – it finds patterns. As such, it’s up to you to pick the patterns you’ve used and this does have a limited functionality if you’ve gone ahead and added dates to your file names.

If you do have numbers in your file names and you don’t have spaces, you can still grep for a pattern. For example, this might work assuming no space in your file name is in front of the year field – which there generally shouldn’t be:

I can’t be too specific because I don’t know if you’ve put numbers/years in your file names. If you have, grep will equally find those. This whole article assumes that you’ve done nothing of the sort.

This can be even handier and here’s a little bit of some bonus information.

Let’s say you have a directory where you’ve stored files for years. Further, you want to know how many files you created in the year 2022. This directory contains files containing many years and you don’t want to just count them.

Well, you can do something about that!

That command lists the files. The grep command then finds files created in 2022. You then pipe that output to the ‘wc’ command to count the lines.

Here’s an example output:

That means I added 8 files to that directory in the year 2023.

It’s pretty complicated. If you have years and spaces in your file names, this isn’t going to work that well for you. If you use patterns that match the output from the ls command, grep will find them. That’s what grep does.

While this does have a bit of a limited use case, it’s more of an exploration of what you can do with two simple commands. Unless you use matching patterns in your file names, this should work just famously for you. Otherwise, not so much – but you can have both fun trying AND you can look for other patterns that you can pass to grep.

Closure:

Well, that was kind of fun. We used the ls and grep commands to find files created on a specific date. There are always so many fun things to do with Linux. Many of these fun things can be done in the terminal. I like to think we both learn and have fun here on this site.

This can also be a handy tool. Let’s say you made some changes and then had some trouble later. You know you added files, but you can’t remember which files those were. Before restoring from a backup, you decide you want to troubleshoot. To do so, you start by finding files you created on the same day that you last changed your system.

Of course, this can be useful in a business setting. If you need to account for a problem, you can find the files created that day. Should there be something amiss, you can find files created on a specific date. If, for example, files were created on a date when no files should have been created… Well, you get the idea.

Perhaps more importantly, this shows what you can do with just two basic Linux commands. You’ll find ls and grep on every single desktop Linux (or server Linux) you touch. There’s no need for you to install something. You don’t have to worry about which package manager you use or building software from scratch because the developers didn’t release a package for your distro. You just use the commands that are already available.

Anyhow, this article is already too long. Sorry about that…

I kid. If I was sorry, I wouldn’t have done it in the first place! Ha! Take that!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Yet Another Way To Find Files By Extension

You might look at the title and think that you’ve seen this before, and you have, but this is another way to find files by extension. That’s right! This is Linux! There’s almost always a variety of ways to think about this. There are almost always a variety of ways to accomplish the same task!

Well, this article will touch on a theme we’ve seen before. We’ve seen it recently. I’ve even explained why you might want to find files by their extension type. Fortunately, I’ve even explained the limitations this has.

See a shell script file could have a .txt extension but still work just fine as a script. Linux cares about the file itself more than it cares about the extension. If you have files mislabeled as an .iso file, this operation will still list them as .iso files. This is only about the extension and using that as a search category. It has limitations.

You can read these articles for more:

Another Way To Locate Files By Extension
Find Multiple Filenames By Extension – With Locate
How To: Find Multiple Filenames By Extension

See? It might seem that this article is like beating a dead horse, but it’s not. There are use cases for all of these options, including the option I’ll give you in this article.

Also, it seems like a good day to take it easy. Life has sent me a bit of extra stress. That won’t stop me from writing this article. It seems nothing will stop me from writing these articles!

The ‘ls’ Command:

This is kind of the sledgehammer way to find files by their extension. It’s a good way. It’s even an easy way to remember, without needing extra commands. At the same time, it’s a pretty basic way to do so.

The first command we’ll work with is one you have installed already. You won’t need to add any software to follow along with this article. We’re simply going to use the ls command to list directory contents. 

If you check the man page for the ls command, you’ll see this:

ls – list directory contents

What did I say in the paragraph before that? I said we’re going to list directory contents. Sure enough, Linux provides the perfect tool for this. 

As an aside, what you can accomplish with a basic Linux install is amazing. You can accomplish a whole lot of work without actually adding any additional software. This is awesome. Thank you, Linux.

The ‘grep’ Command:

The second command we’ll be using is the grep command. If you’re a regular on this site, you’ll have used the grep command many times. You can think of the grep command as a filter. You use the grep command to process the output of another command (more often than not) and, more specifically, you use it to filter that output.

You want to use grep when you’re trying to isolate some information. Well, sure enough, we can check the man page for grep. If you do so, you’ll find that grep accurately describes itself like this:

grep, egrep, fgrep, rgrep – print lines that match patterns

You’ll see that grep comes in many forms. You’ll also see that it’s used to print lines that match patterns. The command is filtering out those lines that don’t match the prescribed pattern.

In fact, I used it as an example in the previous article:

Find Out When A File Was Created

Scroll down to see how you can use the grep command to filter out the lines that aren’t important when you simply want to find out when a file was created. Simple, eh? Yes… Simple!

Find Files By Extension:

As you can guess, we’ll be using both the ‘ls’ command and the ‘grep’ command to find files by extension. As those are terminal-based commands, this will be a terminal-based article. You’ll need to open a terminal and you can (more often than not) do so by pressing CTRL + ALT + T.

With your terminal now open, this is the syntax I want you to use for this exercise. We’ll keep it simple:

If you’ve used mix-case, maybe having extensions of .TXT (in capital letters), you can add the -i flag to the grep command. That will (don’t forget to check the man page) tell the grep command to ignore the case. So, an example of the syntax for that command might be:

For example, I might want to search my ~/Downloads directory for .iso files, finding the various distros I’ve downloaded on this computer. If I wanted to do that, my command would look like this:

And, sure enough, here’s an example output from that very command:

See? That output shows you all the .iso files that I have in my ~/Downloads directory. There’s no fuss. There’s no muss. It’s just a simple way to find files by extension.

Anyone can do it and they won’t need any additional software to do so. Everyone (except maybe someone with a very light embedded Linux system – and probably still them) can find files by extension without adding anything to their system. It’s maybe a bit creative, but it’s effective. I’m not sure about you, but I like effective things. This meets that definition squarely – it’s effective.

Closure:

Well, I guess this is still a fairly long article. I’ve been making them longer and this one just got written that way. My style of longer writing isn’t without thought. I have altered the format of these articles a half-dozen times.

Each time I do so, I do so for you. The goal of altering the format is to make it easier for you to digest and to offer more information than previous articles – even for the more basic articles like this one. I do not know if I’ll settle on this style. Evidence would suggest that I’ll improve upon it as I go.

I welcome feedback on this. I don’t suppose you’ll give me that feedback. The odds are good that you won’t even read this far down. Still, please let me know if you like the current writing style. I’ve consistently written to a formula, but that formula has changed over time. This is the most recent iteration, so please let me know what you think. Thanks!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

List The Files In A Directory

Today’s article is only going to be useful if you are a new user and don’t yet know how to list files in a directory. This is, of course, something you do in a terminal. I do believe this will be a quick and easy article, so read on if you don’t yet know how to list files in a directory.

If you’ve used Linux for more than a month, you can safely ignore this article.

Yes, this has been covered all over the web. This isn’t anything remotely new, nor is it anything all that complicated. However, this is a holiday weekend and I figure it’s a good article for new users who happen to be just browsing around. I’ve also covered some ‘ls’ commands before.

On the other hand, it should be a short article! So, there’s that!

List The Files In A Directory:

Of course, this article requires an open terminal, like many other articles on this site. Should you not know how to open the terminal, you can do so with your keyboard. Press CTRL + ALT + T and your default terminal should open.

With that terminal now open, let’s try a simple command:

That will list all the files in the directory. If you’d like to see the output in columns, you can always try this command which lists the output in a denser manner.

That command doesn’t list dot (hidden) files. Seeing as you’re in the home directory, you should have some hidden files. If you want to use the ‘ls’ command to show files, you need the -a flag. You can combine it with the above and use this command:

That’s the command I use more often than not. This being Linux, you get to decide which how to use the command. I think I type the ‘ls -la‘ command out of habit.

Closure:

Well, you got an article. Sure, it’s a simple article but someone may find this important information. Of course, they could just use the man page   – but what’s the fun in that?

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Show File Sizes When Listing Files In A Directory

Today we’re going to have an easy article that shows you how to show file sizes when listing files in a directory. It’s a simple set of commands and easy enough for a newbie to learn. Though the title is unwieldy, read on to learn how to show file sizes when listing files in a directory…

We’ll be using the ‘ls’ command for this exercise. Like normal, I’ll go ahead and suggest you read this page about why you shouldn’t parse the output from the ‘ls’ command. There are better ways and that link will explain it, and what you should consider, far better than I can.

Anyhow, the ‘ls’ command defines itself as:

ls – list directory contents

Of course, regular readers will recognize the ls command as we’ve used it numerous times before. Even though you shouldn’t parse the output from the command doesn’t mean it’s not still useful for a variety of other tasks.

Today, we’ll be exploring one of those tasks. We’re going to show you how to show file sizes when listing files in a directory – specifically with the ls command. Don’t worry, you won’t need to install anything. If you’re using any desktop Linux distro, the ls command is certainly available to you by default.

For the record, you should probably view the ls man page (run man ls in the terminal) to learn more about the command. It’s still a useful command – and I do sometimes parse the output from the command, but only when nobody is looking and when the output isn’t all that vital. I use grep with the ls command almost every day! Shh!!!

Show File Sizes When Listing Files In A Directory:

(That’s an unwieldy title!)

Anyhow, it’s the ls command. That’s a terminal-based command. So, of course, you’re going to need an open terminal (like so many of these articles). Press CTRL + ALT + T and your default terminal should open. Tada!

With your terminal now open, we can just use your home folder. To run the basic ls command, it’s just that:

Now, to show file sizes when listing files in a directory, you’d start with the -s flag:

You may find the output from that command is relatively useless without doing a bit of math to go along with it. Fortunately, you can tell the command to show the file size in a ‘human-readable format’. To do that, you’d run this command with the -h flag:

Now, if you wanted to show all the files, including the hidden files in that directory, you’d just add the -a flag. The command would look like this:

And if I was a Linux newbie, that’s the command I’d commit to memory. It doesn’t make a mess. The output is still plenty clear. It’s easy to understand. It’s easy to remember and turn into a habit. This way, when you ran the ls command, you just default to using -ash flags.

If you don’t want columns (and some do not), and you want more information such as file permissions or ownership values, you can just add an -lflag to the above. That’d look like:

So, it’s up to you…

You can remember ‘ash’ or you can remember ‘lash’. You can also not remember either and ignore the flags completely, but I find developing a habit is a good way to remember things. It’s your device, you do what you want!

Closure:

There you have it! You have another article. This one was simple enough and I hope you found it useful. If you’re new and running the ls command is new to you, it’s worth learning some additional flags and gathering more information at a glance. That’s why there’s this relatively simple article that shows you how to show file sizes when listing files in a directory.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Learn A Little About The ‘dir’ Command

In today’s article, we’re going to learn about the ‘dir’ command. The ‘dir’ and ‘ls’ command are quite similar, but ‘ls’ seems to get all the press. So, today we’ll be looking at the ‘dir’ command. It will be a relatively short article (I suppose) and easy enough for new people to follow.

You’re possibly already familiar with the ‘ls’ command. I’ve written a variety of articles about ‘ls’. We’ve used ‘ls’ in numerous articles along the way. Here are a couple of ‘ls’ articles:

Some Fun With Sorting The Output Of ‘ls’
Let’s Use ‘ls’ To Sort Files By Time

Those are just a couple. WordPress, the backbone of this site, isn’t very good at searching for just two characters like ‘ls’. That’s for good reason and I’m not sure if that behavior can be changed.

Ah well… Root around and I’m sure you’ll find more. I’ve written about 300 articles and can’t possibly remember them all!

Anyhow, we’ll be using the ‘dir’ command in this article. It describes itself pretty well in the man pages, and is similar to the ‘ls’ command. It describes itself as:

dir – list directory contents

So, if you’re familiar with the ‘ls’ command, you’ll find ‘dir’ to be quite similar. I’m sure there’s a reason that both exist – I’m just not sure what that reason is, nor am I sure why both are included by default. Feel free to let me know your thoughts or theories!

Edit: See this link to see why Linux contains both.

Well then, let’s get on with it…

The ‘dir’ Command:

Well, you shouldn’t need to install anything for this article, but you will need to have an open terminal. By now, you know how to open the terminal if you’re a regular reader, but others need only press CTRL + ALT + T and their default terminal should open.

With your terminal now open, let’s just start with the basics. If you just enter the ‘dir’ command it will output a list of all the visible files in that directory. It looks like:

You can also specify a directory, like:

If you want to show hidden files, you can try this:

If you want to list things in a single column, in a list format, you can just add the -l flag. This also shows the file’s permissions and modification time. So, you could try:

If you want to list files with the ‘dir’ command and to do so recursively (digging into the folders within folders), you can do that too. All you need is the -R flag. So, for example:

That’s just scratching the surface of the ‘dir’ command. There’s a whole lot more that you can do, so just try the man page for more nifty tricks  you can do with ‘dir’.

If you have any questions or nifty ‘dir’ information, please feel free to leave a comment. It’s a pretty handy command to have on hand, much like ‘ls’.

Closure:

And there you have it. You have yet another new article, this one about the ‘dir’ command. It’s not terribly complicated and it’s another tool to toss into your toolbox. You never know when you might want to use it instead of the ‘ls’ command, though they’re awfully similar.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.