5

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
' {} \;
3
  • 4
    What's read line </dev/tty for exactly?
    – Mat
    Apr 20, 2013 at 9:17
  • There is nothing wrong with your command, it is just stuck at read line </dev/tty expecting input. If you type something and hit enter it will continue. What exactly is $line supposed to be?
    – terdon
    Apr 20, 2013 at 13:06
  • 1
    @user21271 Generally speaking, always double-quote your variables to avoid word splitting, i.e. "$file" and "$DIRECTORY". Also, by convention, environment variables (PATH, EDITOR, SHELL, ...) and internal shell variables (BASH_VERSION, RANDOM, ...) are fully capitalized. All other variable names should be lowercase. Since variable names are case-sensitive, this convention avoids accidentally overriding environmental and internal variables. Apr 20, 2013 at 23:03

1 Answer 1

1

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
...
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .