How To Perform Fuzzy File Search In Linux 2022


This tutorial is about how to find fuzzy files in Linux. We will do our best for you to understand this guide. I hope you will like this blog How to Do a Fuzzy File Search in Linux. If your answer is yes, please share after reading this.

Check how to perform a fuzzy file search in Linux

Fzf is a general command line tool for finding fuzzy characters. It is similar to grep. It’s a cross-platform command-line tool that helps you quickly find and open files. Moreover, it is open source, portable and has no dependencies.

Supports Vim/Neo vim plugin, keyboard shortcuts and fuzzy autocomplete. It can be used with any list: files, command history, processes, hostnames, bookmarks, Git commits, etc.

How to Do a Fuzzy File Search in Linux

  • People familiar with a command-line environment are probably familiar with the concept of Unix filters. It is when several independent utilities are joined together in a pipeline to produce the desired result step by step. For example, this pipeline produces a list of strings:
    • $ yes | head -10 | awk ‘{ print NR, NR % 2 == 0? “Strange couple” }’
    • 1 odd2 even3 odd4 even5 odd6 even7 odd8 even9 odd10 even
  • Each program acts as a filter. Simply put, fzf is just another Unix filter. It reads the lines from stdin, launches an interactive browser dialog, and finally writes the selected items to stdout. The key point, and the difference with tools like GNU find, is its interactive Finder dialog that instantly filters items as you type.
  • This may not seem too practical so far, but the main use case for fzf is to find files on the command line. With fuzzy matching and instant feedback, you’re only a few characters away from finding the right file, no matter how lost you are in the directory hierarchy. No need to go back to your file manager, go through the directory hierarchy, copy the path of a file and paste it back into the shell. Compare the “file manager” and “fzf” workflows below.
  • fzf supports fuzzy matching, so you can type multiple characters in a row and it will match lines with those characters scattered throughout the string. You can also prefix a search term with a single quote, such as ‘string, to opt for exact matches only, or run it as fzf –exact .
  • It doesn’t support regular expressions or global patterns, so the *.sh pattern wouldn’t work. But keep it simple: productivity and speed are your goal today. You don’t have free time to compose and write correct regular expressions. Instead, write multiple words, or even parts of words, delimited by a space, and that would cover over 90% of use cases. For the remaining 10%, use ^ and $ to match the start and end of the string respectively, and use ! to cancel the game.
  • Printing selected files on a command line isn’t very useful, so searching is usually associated with an extra action. For example, you can open it with Vim or pipe selected items to the next program.
    • # Open the file in a Vimvim -o `fzf`
    • # Display information for each selected filefzf | xargs ls -l

Final Words: How to Perform a Fuzzy File Search in Linux

Hope you understand this article How to Do a Fuzzy File Search in Linux, if your answer is no, you can ask anything via the contact forum section linked to this article. And if your answer is yes, share this article with your family and friends.


Comments are closed.