A friendly alternative to find in Linux (FD command)

Time:2020-11-29

The FD command provides a simple and straightforward way to search Linux file systems.

FD is an ultra fast, Unix / Linux find replacement for rust. It doesn’t provide all the power of find. However, it does provide enough functionality to cover 80% of the situations you may encounter. Features such as good planning and convenient syntax, color output, intelligent case, regular expression and parallel command execution make FD a very capable successor.

install

Go to the FD GitHub page and view the installation section. It covers how to install programs on MacOS, Debian / Ubuntu red hat, and arch Linux. After installation, you can get a complete overview of all available command-line options by running help, concise help via FD – H, or more detailed help via FD – help.

Simple search

FD is designed to help you easily find files and folders in the file system. You can perform the simplest search using FD with a parameter, which is whatever you want to search for. For example, suppose you want to find a markdown document that contains the word services as part of the file name:


$ fd services
downloads/services.md

If / and / do not match the current directory and / or only search with one parameter. The equivalent search using the built-in find command is as follows:


$ find . -name 'services'
downloads/services.md

As you can see, FD is much simpler and requires less input. In my mind, it’s always right to do more with less input.

Files and folders

You can use the – t parameter to limit your search to files or directories, followed by letters representing what you want to search for. For example, to find all the files in the current directory that contain services in their file names, you can use:


$ fd -tf services
downloads/services.md

And find all the directories in the current directory that contain services in the file name:


$ fd -td services
applications/services
library/services

How do I list all documents with. MD extension in the current folder?


$ fd .md
administration/administration.md
development/elixir/elixir_install.md
readme.md
sidebar.md
linux.md

As you can see from the output, FD can not only find and list the files in the current folder, but also find the files in the subfolders. It’s simple.

You can even use the – h parameter to search for hidden files:


fd -H sessions .
.bash_sessions

Specify directory

If you want to search for a specific directory, the name of the directory can be passed to FD as the second parameter:


$ fd passwd /etc
/etc/default/passwd
/etc/pam.d/passwd
/etc/passwd

In this example, we tell FD that we want to search the etc directory for all instances of the word passwd.

global search

What if you know part of the file name but don’t know the folder? Suppose you download a book about Linux network management, but you don’t know where to save it. no problem:


fd Administration /
/Users/pmullins/Documents/Books/Linux/Mastering Linux Network Administration.epub

summary

FD is an excellent alternative to the find command, and I’m sure you’ll find it as useful as I am. To learn more about this command, just browse the man pages.

The above is the whole content of this article, I hope to help you in your study, and I hope you can support developeppaer more.

Recommended Today

PHP 12th week function learning record

sha1() effect sha1()Function to evaluate the value of a stringSHA-1Hash. usage sha1(string,raw) case <?php $str = “Hello”; echo sha1($str); ?> result f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 sha1_file() effect sha1_file()Function calculation fileSHA-1Hash. usage sha1_file(file,raw) case <?php $filename = “test.txt”; $sha1file = sha1_file($filename); echo $sha1file; ?> result aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d similar_text() effect similar_text()Function to calculate the similarity between two strings. usage similar_text(string1,string2,percent) case […]