BASH scripting will change your life

About this video

This is episode 2 of a Bash scripting series, building a ‘best day ever’ greeting script — framed as a Bash Butler — to teach variables, user input, and command substitution. He first recaps creating the script with nano, adding a shebang, using echo and sleep, and making it executable with chmod +x. He then shows why hardcoding a name is inefficient: a variable (name=“Patricia”) referenced as $name lets one edit change every greeting. Next he makes the script ask for input with read, then replaces that with positional arguments, so $1 supplies the name and $2 supplies a compliment (for example changing ‘beard’ to ’eyes’ for his wife Abby). Finally he stores command output in variables using $(…) syntax — whoami, pwd, and date — and prints the current user, directory, and date inside the greeting. He notes the finished version in his academy also adds private and public IP addresses, weather for a chosen city, and a dad joke of the day. The lab runs in a cloud Linux VM he says costs a penny per hour, with a hundred dollars of free credit for 60 days for new sign-ups.

Key takeaways

  • A Bash variable is set as name=value and expanded as $name, so changing one definition updates every use in the script
  • The read command captures interactive user input directly into a variable at runtime
  • Positional parameters $1, $2, etc. pass values on the command line when the script is launched, in order
  • Command substitution with $(command) stores a command’s output — e.g. whoami, pwd, date — in a variable for reuse
  • Scripts must be made executable (chmod +x) and are run as ./scriptname.sh followed by any arguments

Episode details: published April 12, 2022 · 14:18 long. Summary written by Self Growth Videos from the episode itself. Business results and any income figures mentioned are NetworkChuck’s own claims, shared for education — they are not typical or guaranteed.


← Previous: we ran OUT of IP Addresses!! · Next: what is a List in Python? →

All NetworkChuck videos · NetworkChuck profile · NetworkChuck on YouTube

Sister brand · Vacation Club Promo

All-inclusive resort stays from $435

Qualified couples: promotional Mexico and Caribbean packages at real resorts. Short presentation during your stay — enjoy the rest of the trip.

Qualifications apply · presentation during stay · no purchase required

Subscribe YouTube Suggest