How can I combine the ‘find’ and ‘identify’ commands in Bash?

0
8
Asked By CuriousCat123 On

Hey everyone! I'm trying to figure out how to use the 'find' and 'identify' commands together in Bash, but I'm having some trouble. Here's what I've tried so far: I used 'find . -type f -name "*3434*.jpg"' and 'identify ./'. Now, I'm wondering how to properly combine them. Would something like 'find -name *###*.jpg | identify *' work? Any help would be appreciated! Thanks!

4 Answers

Answered By TechieGuru88 On

You can try this method:
```bash
find -iname '*###*.jpg' -exec identify {} ;
``` This way, it will execute 'identify' on each file found by 'find'.

EagerLearner77 -

That sounds great! I’ll give it a go. Thanks a lot!

InfoJunkie42 -

Just a heads up, while this works, it will run 'identify' separately for each file. Depending on your files, that could slow things down!

Answered By LinuxNinja99 On

You might also want to consider using either '-exec' or piping to 'xargs' for more efficiency.

Answered By BashBro88 On

Another option could be:
```bash
find -name '*###*.jpg' > /tmp/filelist.txt
sed 's/^/identify /g' /tmp/filelist.txt > commands-to-run.sh
```
Make sure to review 'commands-to-run.sh' before you run it. Always double-check to ensure it looks good!

Answered By CodeWizard21 On

If you're looking for another approach, you can also use 'xargs'. It takes input and calls a command with that input as arguments. So if 'identify' only needs one argument at a time, you can adjust 'xargs' to handle that case.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.