Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


find $DIRECTORY -type f -name '*.mov' -exec sh -c '
  echo "Processing $file ..."
  modmovie -notrack "Timecode Track" $file -save-in-place
  read line </dev/tty
' {} \;
share|improve this question
What's read line </dev/tty for exactly? – Mat Apr 20 '13 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 '13 at 13:06
@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. – Rany Albeg Wein Apr 20 '13 at 23:03

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.


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

My script's output

     <---- I hit enter here
     <---- I hit enter here    
     <---- I hit enter here
share|improve this answer
@Yurij73: How do you mean? If you take it out then nothing get's displayed. – slm Apr 20 '13 at 13:30
thanks, this works as a script ! – Yurij73 Apr 21 '13 at 6:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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