Another Way To Locate Files By Extension

I figure that today is a good day for a shorter article, so we’ll look at another way to locate files by extension. This is something that you can do in so many different ways. We’ll just cover another one, simply because we can.

You might want to locate files by extension when you’re doing file management tasks. When you have a directory containing many files, the output from the ls command can be pretty cluttered. For example, you might want only to list the files with a .txt extension. This article will help with that.

It should be noted that Linux doesn’t much care about file extensions. If you create a plain text file without any extension at all and add some text to the file, Linux will know that it’s a text file. See this article on Wikipedia about magic bytes:

List of file signatures

See also this article:

Magic Number on Wikipedia

About a year ago, I wrote a couple of articles on this same subject – that is finding files by extension. Of course, those articles are different than this article. This is a different way to locate files by extension. Those previous articles were:

Find Multiple Filenames By Extension – With Locate
How To: Find Multiple Filenames By Extension

So, finding files by their extension type has been covered before. We’re just going about it another way. The previous examples were a bit convoluted and this is just going to be an “easier” way. (I suspect that it’ll be easier. I guess that depends on what you consider to be easy!)

Locate Files By Extension:

Yes, we’ll be doing this in the terminal. I’m sure there’s a GUI way to do so, but that’s going to be a matter of the file manager you use. They will not all have the same features and not all of them will access those features in the same way. So, let’s get started by opening your terminal – just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, we’ll use the find command again. You almost certainly won’t need to install anything but you can confirm that you have find installed with this command:

See? You have the find application installed already. 

If you check the man page (with man find), you’ll see find is described as:

find – search for files in a directory hierarchy

We’ll also be using grep and a pipe “ |” in this article. You should know that grep helps you sort stuff and that the pipe lets you take the output from one command and use it in another. The pipe is a very underrated tool by people who don’t know much about the terminal.

The command we’ll be using is a find command. The syntax is quite simple and would look something like this:

For example:

The -type f is telling the find command to only look for regular files. Then, the output from that command is then piped to the grep command. After that, the grep command looks for file names that contain a . and the specific extension you’re looking for. The output might look like this:

using find and grep to locate files by extension
This is a fairly new installation and most of my .iso files are stored on the network.

Now, this isn’t going to work if you just use wonky file names. This isn’t going to find files without that extension name. Remember, we’re trying to locate files by extension. We are not determining if the extension is correct and we are not determining what the file really is.

See? Pretty simple!

Closure:

Well, I said today’s article would be shorter. It’s also fairly simple. If you need to locate files by extension, there are many ways to do it. Some methods are easier than others. Perhaps some are more robust than other methods. Either way, you can now locate files by extension type. 

You might also be interested in this article:

Find Out What A File Is

Otherwise…

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.

Search Your Man Pages With Apropos

Today we will show you how to search your man pages with apropos. If you’ve forgotten a command, apropos might be what you’re after. If you aren’t already aware, it’s possible to search your man pages. This article will show you how to do just that.

I should first point out that most folks would use apropos only as a last resort. If you have access to the internet, and you’re a normal human, you don’t need to rely on the rudimentary search that is apropos.

Apropos is great if you can remember a good description of the application you’re thinking of. But, it’s a basic search. It searches just for matching text. The details in the body of the article will hopefully make that more clear. Even still, it can be a useful reminder. I use apropos sometimes, but I think it’s clear that I’m not a normal user.

In fact, apropos is pretty good if you’ve got the command right there on the proverbial tip of your tongue. It’s good if you can remember some words the man page used to describe the application. It’s reasonably good at giving you a list.

After all, let’s face it, even a bare-bones Linux installation has thousands of applications installed. There are more commands than any one person can reasonably remember. If you try to memorize them all, your dinner will get cold and your head will pop off. (Trust me, I’m a doctor!)

Search Your Man Pages With Apropos:

If we’re going to be searching your man pages, we’re going to be doing it in the terminal. So, you’ll need an open terminal for this article. Just press CTRL + ALT + T and your terminal should pop open.

With your terminal open, you might as well check the man page for apropos:

Now, you have two real choices. You can put quotes around your search term to search specifically for those words in that order, or you can just use search terms without quotes which may net more results.

Let’s test this out… Let’s search for “list files”. That seems reasonable, right? We’ll pretend we’re looking for the ‘ls’ command.

Go ahead and try that. You’ll probably get a cheeky message about finding nothing appropriate. 

But, if you try this command, you’ll get a bunch of results:

If you weed through the output from that command, you should find the ‘ls’ command. If you wanted it narrowed down, you’d have wanted to try something like:

If you couldn’t remember ‘ls’ then you’re probably not going to remember the rest of that. So, you can start with the second search (just “list”) and find it that way.

Now, rather than explain it deeper, I’ll just show you what happens if you don’t use quotes. Try the following command:

Sure enough, you’ll find the ‘ls’ command in the output. It’ll give you a bunch of results but you can see that you don’t need to order the words exactly as they are on the man page. It’ll happily search for any those words, regardless of the order they’re in.

Closure:

See? It’s a new article. This time, we’ve decided to cover how to search your man pages with apropos. It’s not the most useful of commands, but it’s available – and probably useful if you don’t have an internet connection. Or, it’s useful for people like me, people who do all sorts of weird stuff in the terminal, sometimes even if there’s a faster or easier way.

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: Search With apt

Today we’ll learn how to search with apt. There are any number of reasons why you’d want to do this. You can use this to find applications by name or subject. Maybe you want to find files that meet a certain criteria? It could be that you’ve forgotten the name of the application you’re thinking of? Perhaps you want to know if an application is available in the repositories before you go seeking it elsewhere?

There are all sorts of reasons, including those, why you might want to search with apt. Obviously, this requires an operating system that uses apt, so that limits you to things like Debian, Ubuntu, official Ubuntu flavors, Linux Mint, etc… So, well, it’s a pretty sizable number of distros where this will work.

This will be a pretty simple article. It will also be pretty brief. I’ve likely mentioned searching in another apt article, but it’s important that we cover it. Alas, I’m running out of things that make for longer articles (in the notes I’m working from), so this is just another article where I’m trying to make you aware that certain tools exist.

This should absolutely be a short and easy to understand article. In some recent commentary, I realized that what’s ‘simple’ to me is something that someone else has been dealing with for the past year. Even my easier articles have the chance to help people figure out their Linux problems. Good… It makes me feel better when I write an ‘easy’ article.

So, with all that said… Let’s learn how to:

Search With apt:

This article pretty much requires an open terminal, like oh so many other articles on this site. If you don’t know how to open the terminal, and you should by now – if you’ve been following along long enough, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Now, it should go without saying, apt is how you interact with your package manager. It’s how you install, uninstall, or otherwise manage your software in the terminal. You could insist on using a GUI to install software, in which case this won’t be of much interest to you, or you could just do it all in the terminal. Either way, if you are using a different package manager then this will be of no value to you.

Me? I prefer to do this sort of stuff in the terminal because I find it easier and faster. I’ve already got a terminal open anyhow, so I might as well use it.

Anyhow, with your terminal open, go ahead and type:

For example:

Seriously, if you’ve never used the search function, go ahead and try the above command. You might be surprised by what you find.

Now, if you’re trying to narrow it down some, you can use the –names-only flag. Which isn’t as accurate as it could be. For example, try:

But, as near as I can tell, that’s searching not just the names but also searching the one-liner description. Like, if you run the above command you’ll also see ‘terminator’, which is definitely not ‘terminal’.

However ‘terminator’ includes ‘terminal’ in the description. So, I’m not sure where that’s going with that and the man pages weren’t all that helpful. You can also use RegEx (Regular Expressions, for the uninitiated). For example,  you can run:

This, of course, only works if you have Google’s Chrome repositories enabled. Otherwise, pick something else to test this with. Or, just trust me when I say RegEx works, which the man page will confirm.

Anyhow, our example command from above would (on this computer) would have an output that looks like this:

Which, as you can see, means I have multiple versions of Chrome available. So, that’s something positive in my life! But, the point is, I did a search with apt and came away with the information I wanted. I’d normally send you to the application’s man page, but in that probably won’t make it all that much clearer. 

Closure:

Yeah, that’s it. You can now search with apt and find what you’re looking for. Use some of your own search terms, like apt-cache search image editor, and see what sorta results you get. It’s not the most refined, but it’s an effective way to search with apt.

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.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.