Bash – Execute multiple bash commands on the output of find

bashfindosx

I want to execute some commands using the find -exec option, but I'm not sure what' wrong with this code. Currently, it's only processing the first find result, then getting stuck. I'm using bash in OS X.

read -e DIRECTORY

find $DIRECTORY -type f -name '*.mov' -exec sh -c '
  file="$0"
  echo "Processing $file ..."
  modmovie -notrack "Timecode Track" $file -save-in-place
  read line </dev/tty
' {} \;

Best Answer

I came up with this example and as others have said in the comments it's the read line </dev/tty that's causing it to wait for user input.

#!/bin/bash

find db -type f -name '*.jpg' -exec sh -c '
file="$0"
echo "hi"
echo "$file"
read line </dev/tty
' {} \;

My script's output

hi
db/db1440/gothamgardenxmas21440.jpg
     <---- I hit enter here
hi
db/db1440/unveiling11440.jpg
     <---- I hit enter here    
hi
db/db1440/astronomer21440.jpg
     <---- I hit enter here
...
Related Question