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
You can try this method:
```bash
find -iname '*###*.jpg' -exec identify {} ;
``` This way, it will execute 'identify' on each file found by 'find'.
Just a heads up, while this works, it will run 'identify' separately for each file. Depending on your files, that could slow things down!
You might also want to consider using either '-exec' or piping to 'xargs' for more efficiency.
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!
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.
That sounds great! I’ll give it a go. Thanks a lot!