Home > Software design >  find -print0 with 2 files only shows 1
find -print0 with 2 files only shows 1

Time:11-08

As an example, I have two files in my directory:video.mp4 and video.webm If I use:

find . -maxdepth 1 -type f -iname "*.mp4" -o -iname "*.webm"

I got correctly:

/video.webm
./video.mp4

But if I add -print0, that I need to pipe to parallel I got:

./video.webm

What I'm doing wrong?

CodePudding user response:

Assuming your print0 attempt looks like:

find . -maxdepth 1 -type f -iname "*.mp4" -o -iname "*.webm" -print0

The -print0 is processed with the 2nd -iname option, in effect:

find . -maxdepth 1 -type f -iname "*.mp4" -o ( -iname "*.webm"  -print0)

One option would be to add explicit parens to insure the -print0 is applied against both -iname options, eg:

find . -maxdepth 1 -type f \( -iname "*.mp4" -o -iname "*.webm" \) -print0
  • Related