Bash

Iterate Integers


for i in {0..22}; do echo "$i"; done

# With fixed width:
for i in {00..22}; do echo "$i"; done

Redirect Named Pipe into Background Process


# Create a named pipe.
mkfifo p

# Pipe named pipe into process.
cat p | /path/to/program args &

# In a subshell, echo commands into named pipe.
(
    # Wait for target to spawn shell.
    sleep 0.1

    # Send commands.
    echo "id" >p
)

Wait Until File Exists


while [ ! -f /path/to/file  ]; do sleep 1; done