1

On my image folder i want only images,so i will find all video files "intruders" using this command(found somewhere on stackexchange)

find folder/imageonly  -type f -exec file -N -i -- {} + |sed -n 's!: video/[^:]*$!!p'

But if i want a reverse search? For example i want to find all not video files in video folder?

p.s=i don't use extensions,so flags "file -N -i.." must be used

1

Add an address range to your sed:

find folder/imageonly  -type f -exec file -N -i -- {} + |
  sed -n '/: video\/[^:]*$/!s!: [[:alnum:]]*/[^:]*$!!p'

/: video\/[^:]*$/! tells it to run the commands on every line that doesn't match the pattern, which you used for matching videos.

2

I'd just use grep instead of sed (mainly because i have no experience with sed). But the following should work (and does on my system):

find .  -type f -exec file -N -i -- {} + | grep -v 'video/' | cut -d : -f 1

This expects that there are no : in the filenames though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.