Separate Output Entries Without New Line Using locate Command

locate -i -0 *sample.txt*

Default separator for locate command is the newline (\\n) character. But if someone wants to use a different separator like the ASCII NULL, then he/she can do so using the -0 command line option.

locate command in Linux with Examples

locate command in Linux is used to find the files by name. There are two most widely used file-searching utilities accessible to users called to find and locate. The locate utility works better and faster than the find command counterpart because instead of searching the file system when a file search is initiated, it would look through a database. This database contains bits and parts of files and their corresponding paths on your system. By default, locate command does not check whether the files found in the database still exist and it never reports files created after the most recent update of the relevant database.

Table of Content

  • Syntax of `locate` command in Linux 
  • Options Available in `locate` command in Linux
  • Search a File with Specific Name Using locate Command
  • Limit Search Queries to a Specific Numbe Using locate Command
  • Display The Number of Matching Entries Using locate Command
  • Ignore Case Sensitive Locate Outputs Using locate Command
  • Separate Output Entries Without New Line Using locate Command

Similar Reads

Syntax of `locate` command in Linux

locate [OPTION]... PATTERN......

Options Available in `locate` command in Linux

...

Search a File with Specific Name Using locate Command

locate sample.txt...

Limit Search Queries to a Specific Numbe Using locate Command

locate "*.html" -n 20...

Display The Number of Matching Entries Using locate Command

locate -c [.txt]*...

Ignore Case Sensitive Locate Outputs Using locate Command

This command is configured to process queries in a case sensitive manner. It means SAMPLE.TXT will show a different result than sample.txt....

Separate Output Entries Without New Line Using locate Command

locate -i -0 *sample.txt*...

Conclusion

In this article we have discussed the `locate` command in Linux which is a valuable tool for quickly searching for files and directories. It uses a pre-built database which allows for fast and efficient searches, making it an ideal choice for locating files in a large file system. Overall, we can say that by mastering the `locate` command and its various options, we can save time and effort when searching for specific files or directories on our Linux system....