Combine two bash find commands

bash

I have two similar find commands that I basically have the same code for both once the while loop begins. I want to combine them so I only need one find to search through files and directories, instead of one to search directories and one to search files. Here are the two that I want to combine into one line:

find "$ORIG_DIR" -name "*" -type d | while read dname

find "$ORIG_DIR" -name "*" -type f | while read fname

Best Answer

You can provide multiple -type options with -o, such as -type d -o -type f in a single command.

find "$ORIG_DIR" -name "*" -type d -o -name "*" -type f | while read file

-o matches all parameters, so the -name is provided twice in the above command.