Close Menu
  • Analog Design
    • Latest Analog Layout Interview Questions (2025)
  • Digital Design
    • Digital Electronics Interview Question(2025)
    • Top VLSI Interview Questions
  • Physical Design
    • Physical Design Interview Questions for VLSI Engineers
  • Verilog
    • Verilog Interview Questions(2024)
  • Forum
Facebook Instagram YouTube LinkedIn WhatsApp
SiliconvlsiSiliconvlsi
Forum Questions Register in Forum Login in Forum
Facebook Instagram YouTube LinkedIn WhatsApp
  • Analog Design
    • Latest Analog Layout Interview Questions (2025)
  • Digital Design
    • Digital Electronics Interview Question(2025)
    • Top VLSI Interview Questions
  • Physical Design
    • Physical Design Interview Questions for VLSI Engineers
  • Verilog
    • Verilog Interview Questions(2024)
  • Forum
SiliconvlsiSiliconvlsi
Home»Linux»What is a Linux locate Command?
Linux

What is a Linux locate Command?

siliconvlsiBy siliconvlsiJanuary 22, 2024No Comments2 Mins Read
Facebook Pinterest LinkedIn Email WhatsApp
Share
Facebook Twitter LinkedIn Pinterest Email

locate Command in Linux

Linux locate Command

The locate command in Linux is used to search for files in a system. It relies on a pre-built database that contains the paths of files and directories. The locate command is faster than the find command as it searches the pre-built database rather than the file system.

Syntax

locate [OPTION]... PATTERN...

Options: Here are some useful options for the locate command:

-A or --all: Display only entries that match all patterns instead of requiring only one of them to match.

Example:

locate -A file1 file2

-b or --basename: Match only the base name against the specified patterns.

Example:

locate -b filename

-c or --count: Write the number of matching entries instead of writing file names.

Example:

locate -c filename

-d or --database DBPATH: Replace the default database with DBPATH.

Example:

locate -d /path/to/custom/database filename

-h or --help: Display help documentation.

Example:

locate -h

-i or --ignore-case: Ignore case sensitivity of the specified patterns.

Example:

locate -i FILE

-l or --limit or -n LIMIT: Exit successfully after finding LIMIT entries.

Example:

locate -l 5 filename

-m or --mmap: Ignore compatibility with BSD and GNU locate.

Example:

locate -m filename

-0 or --null: Separate entries with the ASCII NUL character instead of writing each entry on a separate line.

Example:

locate -0 filename

-S or --statistics: Write statistics about each read database to standard output.

Example:

locate -S

-r or --regexp REGEXP: Search using a basic regexp REGEXP.

Example:

locate -r 'pattern.*'

--regex: Describe all patterns as extended regular expressions.

Example:

locate --regex 'pattern.*'

-V or --version: Display version and license information.

Example:

locate -V

-w or --wholename: Match only the whole path name in specified patterns.

Example:

locate -w filename

Examples:

Basic Usage:

locate filename

Limiting Search Results:

locate -n 10 "*.txt"

Displaying the Number of Matching Entries:

locate -c filename

Ignoring Case Sensitivity:

locate -i "siliconvlsi.txt"

Updating the mlocate Database:

sudo updatedb

Displaying Only Available Files:

locate -i -e *siliconvlsi.txt*

The locate command is a powerful tool for quickly searching for files on a Linux system based on a pre-built database, providing faster results compared to some other file search methods.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

Related Posts

Delete words after certain word in each line in gvim

January 28, 2024

Linux date Command

January 22, 2024

du Command in Linux

January 20, 2024
Leave A Reply Cancel Reply

Facebook X (Twitter) Instagram Pinterest Vimeo YouTube
  • About Us
  • Contact Us
  • Privacy Policy
© 2025 Siliconvlsi.

Type above and press Enter to search. Press Esc to cancel.