Skip to content

Inputs¤

Read user input and assign to variable¤

read -p name "Enter  a name: "

echo "${name}"
#!/usr/bin/env bash

declare names=()

while true; do
  read -p "Enter name (q exit): " name
  if [[ "${name}" == "q" ]]; then
    break
  fi
  names+=("${name}")
done

for i in ${names[@]}; do
  echo "${i}"
done

Press any key to continue ...¤

while read -r -n 1 key; do
  if [ "$key" == "y" ]; then
    echo "Break .."
    break
  fi
  echo "Continue"
done
Back to top