Take the 2-minute tour ×
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.

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
' {} \;
share|improve this question
4  
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
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. –  Rany Albeg Wein Apr 20 '13 at 23:03
add comment

1 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
...
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
add comment

Your Answer

 
discard

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.