+4 votes
39 views
How to use FD Linux command

in Linux/Unix by (295k points)
reopened | 39 views

1 Answer

+5 votes
Best answer

The Linux commands are an essential part of the system because they are the ones that we allow you to perform hundreds of tasks of all kinds in the system, whether information, install a program or application , or create and edit user, everything is always linked to a command , many commands are more important than others and one of these is the FD command which we will analyze with TechnoWikis and we will see how it will help routine tasks at https: //www.solvetic...y/8-linux-unix/ Linux..

 

What is the FD command in Linux
Although the first thought is Find, if you have something that relates it to Find only FD simplifies the tasks we carry out with Find.

 

FD has been developed as a much simpler solution to find elements in Linux and one of its main advantages is that it is much faster than we think, when using the FD command we will come across a recursive command which does not do the analysis in hidden directories by default, it is fully Git compliant and is not case sensitive.

 

 

FD command features on Linux
Among its main characteristics we find:
  • Features a colored terminal output identical to ls
  • Integrates the fd PATTERN syntax instead of find -iname '* PATTERN *'.
  • Has regular expressions
  • Unicode support
  • Ignore hidden files and directories by default
  • Ignore the patterns of your default .gitignore
  • When using FD, the search is not case sensitive by default, we can set the search to be case sensitive only if the pattern contains an uppercase character *.
  • The command name is 50% shorter * than find which simplifies the search action
  • Another point of FD is that it is in the ability to color the files according to their extension, in this case the environment variable LS_COLORS must be set.

 

 

Let's see how to use the FD command in Linux completely..

 


1. Install FD command on Linux

 

Step 1

For this case we will use Ubuntu 20.04, to install it there we access the terminal and execute:
 sudo apt install fd-find 
image

 

 

Step 2

In case of having other distributions we can execute the following:

 

  • Fedora: sudo dfn install fd-find
  • Manjaro: sudo pacman -Syu fd
  • Alpine: apk add fd
  • Gentoo: emerge -av fd

 

Step 3

Once installed we check the current version of FD with the following command:
 fdfind –version 
image

 


2. Use FD command in Linux

 

Step 1

In case of using FD without any parameter we will see that the result is similar to ls, the difference is that FD lists the files in default subdirectories:
 fdind 
image

 

 

Step 2

We can perform a search by extension type, for this we must use the -e (extension) parameter like this:
 fdfind -e .docx 
Step 3

This will display the path and name of the files with that particular extension:

 

 

 

image

 

 

Step 4

It is also possible to search for an object by its name:
 fdfind "name" 
image

 

Step 5

In case the search should start in a particular directory, it will be necessary to add the file path in the command line, for example:
 fdfind conf / etc 
Step 6

This will display all the results that include "conf":

 

 

 

image

 

 


3. Find directories and files with FD in Linux

 

Step 1

The fd command is able to search for directories, files (executables and voids) and symbolic links, for a complete search we use the -t (type) parameter with one of the following available options:

 

  • f: file (file)
  • d: directory (directory)
  • l: symbolic link
  • x: executable file
  • e: empty file

 

Step 2

Let's find the Downloads directory:
 fdfind -td Downloads 
image

 

 

Step 3

For the use of capital letters we will see the behavior of FD, in this case we will carry out the following search.

 

Note that with the search for "TechnoWikis" I launch both results while with "TechnoWikis" I only display the one that met the capital letter.

 fdfind -tf TechnoWikis fdfind -tf TechnoWikis 
image

 

 


4. Execute commands with FD in Linux

 

Step 1

We can use FD to start another command and execute it on each files that are detected, we look for .deb files:
 fdfind -e deb 
image

 

 

Step 2

Or we can search for ZIP files, for example:

 

image

 

 

Step 3

It is possible to use the -x (exec) option, in order to run the found file to another command to be processed, we will use "{}" which is a placeholder that represents the file that has been detected:
 fdfind-e zip -x unzip {} 
image

 

 

Step 4

When executing this command, the file will be unzipped in the current working directory that we are in, in case you want it to be unzipped in another directory we must use the following:

 

  • {}: full path of the file and the name of the file that has been detected
  • {/}: name of the detected file
  • {//}: directory containing the detected file
  • {/.}: name of the found file, without its extension

 

Step 5

In order for the file in this example to be downloaded to its source directory, we must execute the following:
 fdfind-e zip -x unzip {} -d {//} 
image

 

 


5. FD Linux command options

 

Step 1

The general syntax for use is as follows:
 fd [FLAGS / OPTIONS] [<origin>] [<path> ...] 
FD parameters
The general parameters of use in FD are:

 

  • -H, --hidden: search for hidden files and directories
  • -I, --no-ignore: ignore files
  • -s, - case sensitive: makes the search case sensitive
  • -g, --glob: Glob based search
  • -a, --absolute-path: display absolute rather than relative paths
  • -l, --list-details: use a long listing format with file metadata
  • -L, --follow: follow symbolic links
  • -p, --full-path: search for complete paths
  • -0, --print0: results are separated by null character
  • -h, --help: display command help
  • -V, --version: allows to see the used version of FD
  • -d, --max-depth <level>: defines the maximum search depth
  • -t, --type: filter search by type
  • -e, --extension: filter by file extension
  • -x, --exec: run a command for each search result with FD
  • -c, --color: set when to use colors

 

 

FD is a functional alternative to perform dynamic searches on Linux with great results and configuration advantages..

 


by (1.8m points)

Related questions

+5 votes
1 answer
asked Jul 16 in Linux/Unix by backtothefuture (295k points) | 14 views
+4 votes
1 answer
+5 votes
1 answer
asked Apr 30 in Linux / Unix by backtothefuture (295k points) | 42 views
+5 votes
1 answer
asked Feb 22 in Linux / Unix by backtothefuture (295k points) | 19 views
+4 votes
1 answer
asked Feb 18 in Linux / Unix by backtothefuture (295k points) | 14 views
Please leave a comment about whether the solution works or not (with device model)   [X]Close
5,628 questions
5,718 answers
128 comments
2 users