Skip to main content
Copy edited (e.g. ref. <https://en.wiktionary.org/wiki/let%27s#Etymology>).
Source Link

How can I recursively delete all empty files and directories in Linux?

How can I recursively cleanup all empty files and directories in a parent directory. Lets?

Let’s say I have a dirthis directory structure:

Parent/
  |____Child1/
        |______ file11.txt (empty)
        |______ Dir1/ (empty)
      
  |____Child2/
        |_______ file21.txt 
        |_______ file22.txt (empty)
        
  |____ file1.txt 

I should end up with this:

Parent/
  |____Child2/
        |_______ file21.txt 

  |____ file1.txt

How can I recursively delete all empty files and directories in Linux

How can I recursively cleanup all empty files and directories in a parent directory. Lets say I have a dir structure

Parent/
  |____Child1/
        |______ file11.txt (empty)
        |______ Dir1/ (empty)
      
  |____Child2/
        |_______ file21.txt 
        |_______ file22.txt (empty)
        
  |____ file1.txt 

I should end up with this

Parent/
  |____Child2/
        |_______ file21.txt 

  |____ file1.txt

How can I recursively delete all empty files and directories in Linux?

How can I recursively cleanup all empty files and directories in a parent directory?

Let’s say I have this directory structure:

Parent/
  |____Child1/
        |______ file11.txt (empty)
        |______ Dir1/ (empty)

  |____Child2/
        |_______ file21.txt
        |_______ file22.txt (empty)

  |____ file1.txt

I should end up with this:

Parent/
  |____Child2/
        |_______ file21.txt

  |____ file1.txt
improved formatting
Source Link

How can I recursively cleanup all empty files and directories in a parent directory. Lets say I have a dir structure

Parent/
  |____Child1/
        |______ file1file11.txt (empty)
        |______ Dir1/ (empty)
      
  |____Child2/
        |_______ file1file21.txt (non empty)
        |_______ file2file22.txt (empty)
        
  |____ file1.txt (non empty)

I should end up with this

Parent/
  |____Child2/
        |_______ file1file21.txt 

  |____ file1.txt

How can I recursively cleanup all empty files and directories in a parent directory. Lets say I have a dir structure

Parent/
  |____Child1/
        |______ file1.txt (empty)
        |______ Dir1/ (empty)
      
  |____Child2/
        |_______ file1.txt (non empty)
        |_______ file2.txt (empty)
        
  |____ file1.txt (non empty)

I should end up with this

Parent/
  |____Child2/
        |_______ file1.txt 

  |____ file1.txt

How can I recursively cleanup all empty files and directories in a parent directory. Lets say I have a dir structure

Parent/
  |____Child1/
        |______ file11.txt (empty)
        |______ Dir1/ (empty)
      
  |____Child2/
        |_______ file21.txt 
        |_______ file22.txt (empty)
        
  |____ file1.txt 

I should end up with this

Parent/
  |____Child2/
        |_______ file21.txt 

  |____ file1.txt
Became Hot Network Question
added 23 characters in body
Source Link

How can I recursively cleanup all empty files and directories in a parent directory. Lets say I have a dir structure

Parent/
  |____Child1/
        |______ file1.txt (empty)
        |______ Dir1/ (empty)
      
  |____Child2/
        |_______ file1.txt (non empty)
        |_______ file2.txt (empty)
        
  |____ file1.txt (non empty)

I should end up with this

Parent/
  |____Child2/
        |_______ file1.txt 

  |____ file1.txt

How can I recursively cleanup all empty files and directories in a parent directory. Lets say I have a dir structure

Parent/
  |____Child1/
        |______ file1.txt (empty)
        |______ Dir1/ (empty)
      
  |____Child2/
        |_______ file1.txt 
        |_______ file2.txt (empty)
        
  |____ file1.txt

I should end up with this

Parent/
  |____Child2/
        |_______ file1.txt 

  |____ file1.txt

How can I recursively cleanup all empty files and directories in a parent directory. Lets say I have a dir structure

Parent/
  |____Child1/
        |______ file1.txt (empty)
        |______ Dir1/ (empty)
      
  |____Child2/
        |_______ file1.txt (non empty)
        |_______ file2.txt (empty)
        
  |____ file1.txt (non empty)

I should end up with this

Parent/
  |____Child2/
        |_______ file1.txt 

  |____ file1.txt
Source Link
Loading