#!/bin/bash
#
# Syntax:
#         until test-commands; do consequent-commands; done
#
# 'consequent-commands' is executed until 'test-commands' has a a non-zero
# exit status.
#
# Example: wait until a file appears in the current directory

file="killme.flag"
echo "Waiting for $file to appear"

until [ -f "$file" ]
do
    sleep 1
done
echo "$file found!"

# Example 2: do something with user input until quit command 
input=""
until [ "$input" = "quit" ]; do
    read -p "Type something (or 'quit'): " input
    echo "You typed: $input"
done
echo "Goodbye!"

