Ubuntu 18.04 – shell commands locate

How to find a file

locate command helps you find files by name.

#syntax locate filename
locate x11
How to find a file, <span>Ubuntu 18.04 – shell commands locate</span>, KandZ

If you installed new files or created a new file, locate will not find the files.

touch newfile    #create newfile
locate newfile    #search for the file but no results

You need to update the mlocate.db database by using:

sudo updatedb

now you can find the file

locate newfile
How to find a file, <span>Ubuntu 18.04 – shell commands locate</span>, KandZ

If you want to count only the times the search exists in the database then add -c parameter:

locate -c newfile
How to find a file, <span>Ubuntu 18.04 – shell commands locate</span>, KandZ

If you do not want all the result but some for example 10, then add -n 10

locate x11 -n 10
How to find a file, <span>Ubuntu 18.04 – shell commands locate</span>, KandZ

More information here

THE END!!!

77710cookie-checkUbuntu 18.04 – shell commands locateUbuntu 18.04 – shell commands locate

Related posts

2 Thoughts to “Ubuntu 18.04 – shell commands locate

  1. […] Ubuntu 18.04 – shell commands locate […]

  2. […] Ubuntu 18.04 – shell commands locate […]

Comments are closed.