17 lines
		
	
	
	
		
			338 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
	
		
			338 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/bin/sh
 | 
						|
# recursively delete empty directories
 | 
						|
 | 
						|
rmdir_empty() {
 | 
						|
  # make default . explicit
 | 
						|
  if [ -z "$1" ]; then
 | 
						|
    set -- .
 | 
						|
  fi
 | 
						|
 | 
						|
  # do the first level directories first
 | 
						|
  for maxdepth_opt in "-maxdepth 1" ""; do
 | 
						|
    find "$@" -depth -mindepth 1 $maxdepth_opt \
 | 
						|
      -type d -empty -exec rmdir -v {} \;
 | 
						|
  done
 | 
						|
}
 | 
						|
 | 
						|
rmdir_empty "$@"
 |