Skip to content

Instantly share code, notes, and snippets.

@kaihendry
Created August 10, 2012 09:35
Show Gist options
  • Select an option

  • Save kaihendry/3312962 to your computer and use it in GitHub Desktop.

Select an option

Save kaihendry/3312962 to your computer and use it in GitHub Desktop.
wait_for() # http://stackoverflow.com/questions/11827252
{
np=$(mktemp -u)
mkfifo $np # named pipe needed to get output out of inotifywait
inotifywait -m -e create "$(dirname $1)" > $np 2>&1 &
ipid=$!
while read output
do
if test -p "$1"
then
kill $ipid
break
fi
done < $np
rm -f $np
}
wait_for /tmp/foobar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment