A friendly alternative to find in Linux (fd command)

A friendly alternative to find in Linux (fd command)

The fd command provides a simple and straightforward way to search the Linux file system.

fd is a blazingly fast, Rust-based replacement for the Unix/Linux find command. It does not provide all of the powerful features of find. However, it does provide enough functionality to cover 80% of the situations you are likely to encounter. Features such as well-planned and convenient syntax, colored output, smart casing, regular expressions, and parallel command execution make fd a very capable successor.

Install

Go to the fd GitHub page and see the installation section. It covers how to install programs on macOS, Debian/Ubuntu Red Hat, and Arch Linux. Once installed, you can get a complete overview of all available command line options by running help, fd -h for concise help, or fd --help for more detailed help.

Simple search

fd is designed to help you easily find files and folders in your file system. You can perform the simplest search using fd with a single argument, which is whatever you are searching for. For example, suppose you want to find Markdown documents that contain the word services as part of the file name:

$ fd services
downloads/services.md

If called with only one argument, fd recursively searches the current directory for any files and/or directories that match the given argument. An equivalent search using the built-in find command would be:

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

As you can see, fd is much simpler and requires less typing. Doing more with less input is always right in my mind.

Files and folders

You can limit the search to files or directories using the -t parameter followed by the letter that represents what you are searching for. For example, to find all files in the current directory that contain services in their filenames, you could use:

$ fd -tf services
downloads/services.md

And, find all directories in the current directory whose file names contain services:

$ fd -td services
applications/services
library/services

How to 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 files in the current folder, but also find files in subfolders. It's very simple.

You can even search for hidden files using the -H switch:

fd -H sessions .
.bash_sessions

Specify a directory

If you want to search a specific directory, the name of the directory can be passed as the second argument to fd:

$ 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 not the folder? Suppose you downloaded a book on Linux network administration, but you don't know where it is saved. No problem:

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

Summarize

fd is an excellent replacement for the find command and I'm sure you'll find it as useful as I do. To know more about the command, just browse the man page.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Get the execution time of a program segment using the gettimeofday function in Linux [Recommended]
  • Detailed explanation of fdisk command usage under Linux
  • Example analysis of the conversion between file descriptor fd and file pointer FILE* in Linux
  • Linux new API signalfd, timerfd, eventfd usage instructions
  • Using Linux's timerfd_create to implement a timer example

<<:  MySQL 8.0.11 installation tutorial with pictures and text

>>:  A brief discussion on the implementation principle of Vue slot

Recommend

How to view the IP address of the Docker container

I always thought that Docker had no IP address. I...

Bootstrap3.0 study notes table related

This article mainly explains tables, which are no...

37 Tips for a Good User Interface Design (with Pictures)

1. Try to use single column instead of multi-colum...

Markup language - specify CSS styles for text

Click here to return to the 123WORDPRESS.COM HTML ...

Specific use of MySQL operators (and, or, in, not)

Table of contents 1. Introduction 2. Main text 2....

How to make JavaScript sleep or wait

Table of contents Overview Checking setTimeout() ...

Sharing of two website page translation plug-ins

TranslateThis URL: http://translateth.is Google T...

Summary of pitfalls in importing ova files into vmware

Source of the problem As we all know, all network...

A brief discussion on the correct approach to MySQL table space recovery

Table of contents Preliminary Notes Problem Repro...

IE8 Developer Tools Menu Explanation

<br />This article has briefly explained the...

Detailed analysis of MySQL instance crash cases

[Problem description] Our production environment ...

Summary of the differences between Vue's watch, computed, and methods

Table of contents 1 Introduction 2 Basic usage 2....