Finding things in Linux CLI

Finding things in Linux CLI

Jul 10, 2012

Every once in a while you might need to search a folder or a file that you or the previous owner of the server/computer has put somewhere – and on command line interface it could be a serious hassle to do that just by browsing through the folders and files.

That’s why  it’s more convenient to use “locate” command on the CLI.

Command should looks something like that:

 Bash |  copy code |? 
1
locate filename.something

In some cases there might be something you want to add to the query just to narrow down the search – then you should use the grep command. Grep is a command-line utility for searching plain-text data sets for lines matching a regular expression. Grep was originally developed for the Unix operating system, but is available today for all Unix-like systems. Its name comes from the ed command g/re/p (global / regular expression / print).

For example lets find a .jpg image called nature:

 Bash |  copy code |? 
1
locate nature |grep .jpg

It will narrow down the search query and will give you more accurate answers.