• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Find A File In Linux In All Directories Recursively

How To Find A File In Linux In All Directories Recursively

By Sourabh / March 21, 2022 Category: How To, Ubuntu

How to find file in subdirectories Linux – find file recursively in Linux. Here is the Unix command to find a file in a directory and subdirectory.

What is Recursive Listing of a Directory

Recursive means if a directory has subdirectories and files, the command will be executed and applied on those files too (recursively).

The simplest way to see the list of files and sub-directories in any specific directory is using tree command.

Tree is a recursive directory listing program that produces a depth indented listing of files. With no arguments, tree lists the files in the current directory. When directory arguments are given, tree lists all the files and/or directories found in the given directories each in turn. Upon completion of listing all files/directories found, tree returns the total number of files and/or directories listed.

tree comamnd

Here is an easier way to perform the recursive search with the tree command:

tree -a

When -a is used with the tree command, all files are printed. By default tree does not print hidden files (those beginning with a dot .’). Also, in no event does tree print the file system constructs.’ (current directory) and `..’ (previous directory).

Combine ‘find’ and ‘grep’

You can also use a combination of two commands in Linux – find and grep commands to recursively search subdirectories for files that match a grep pattern (provided with the argument):

find . -type f -exec grep -l 'directory_name' {} \;

This command makes the task very simple. It searches all files in all subdirectories of the current directory’, and print the filenames. It is a great set of commands to recursively searching files in all subdirectories.

Other Commands to Find Files Recursively

There are many other commands to find files recursively. Linux Ubuntu users can use any one of the following commands:

  1. ls -R : Use the ls command to get recursive directory listing on Linux systems
  2. find /dir/ -print : Use the find command to see recursive directory listing in Unix systems
  3. du -a . : Use the du command to view recursive directory listing on Unix systems

Primary Sidebar

Latest Posts

Delete Directory And Contents Recursively Without Prompt On Linux

Check User Login History In Ubuntu Linux Command Line

Use Locate Command To Find File In Linux Terminal By Name

How To Change Terminal Color In Ubuntu Command Line

How To Run Fsck Manually In Linux To Fix Unexpected Inconsistency

How To Fix Broken Packages On Ubuntu From Terminal

Re Execute The Previous Command In Linux Ubuntu Command Line

How Much RAM Is Needed For Ubuntu PC

How To Find Large Files And Directories In Linux Command Line

How To Use Clear Command History In Linux Terminal

© 2026 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap