Linux – Unix displays information about files that match one of the two modes

Unix displays information about files that match one of the two modes… here is a solution to the problem.

Unix displays information about files that match one of the two modes

I tried to recursively display all files that start with a or end with a and some information about them on Unix systems: name, size and last modified.

I tried find. -name “*a” -o -name “a*” It shows all files normally, but when I add -printf "%p %s" it only shows one result.

Solution

If you want to apply the same Action to both modes, you need to group them in parentheses. Also, you should add a newline character in printf, otherwise all the output will be on one line:

find . \( -name "*a" -o -name "a*" \) -printf "%p %s\n"

Related Problems and Solutions