Skip to content

Instantly share code, notes, and snippets.

@nilforooshan
Created March 13, 2024 10:19
Show Gist options
  • Save nilforooshan/bd5441689afe23fef96834c8598f7b64 to your computer and use it in GitHub Desktop.
Save nilforooshan/bd5441689afe23fef96834c8598f7b64 to your computer and use it in GitHub Desktop.
sh: Store a parameter in a file and read it as a variable

Store a parameter in a file and read it as a variable

cat file.txt

121

read -r myNumber < file.txt
echo "The number is: $myNumber"

The number is: 121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment