Skip to content

Instantly share code, notes, and snippets.

@richiethomas
Created September 23, 2023 10:55
Show Gist options
  • Save richiethomas/007060f8d5d72142abdd3ac7f8d7578b to your computer and use it in GitHub Desktop.
Save richiethomas/007060f8d5d72142abdd3ac7f8d7578b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if [ ! -t 0 ]; then
echo "Standard input is not a terminal. Reading input from non-interactive source."
cat > output.txt
else
echo "Standard input is a terminal. Waiting for user input interactively."
read -p "Enter your input: " user_input
echo "You entered: $user_input"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment