Sitemap
DevOps.dev

Devops.dev is a community of DevOps enthusiasts sharing insight, stories, and the latest development in the field.

Linux — Shell Scripting Basics

7 min readJul 10, 2024

--

Press enter or click to view image in full size

The purpose of this hands-on training is to teach you how to script in shell.

Learning Outcomes

At the end of this hands-on training, you will be able to;

  • explain shell scripting basics.
  • explain shell variables.
  • do simple arithmetic.

Outline

  • Part 1 — Shell Scripting Basics
  • Part 2 — Shell Variables
  • Part 3 — Simple Arithmetic

Part 1 — Shell Scripting Basics

  • Create a folder and name it shell-scripting.
mkdir shell-scripting && cd shell-scripting
  • Create a script file named basic.sh. Note all the scripts would have the .sh extension.
#!/bin/bash
echo "Hello World"
  • Before we add anything else to our script, we need to alert the system that a shell script is being started. This is done specifying #!/bin/bash on the first line, meaning that the script should als be run with bash, rather than another shell. #! is called a shebang because the # symbol is called a hash, and the ! symbol is called a bang.
  • After to save the above content, we need to make the script executable.

--

--

DevOps.dev
DevOps.dev

Published in DevOps.dev

Devops.dev is a community of DevOps enthusiasts sharing insight, stories, and the latest development in the field.