First example in linux shell scripting

You should remember below things while writing the scripts.
  • Every script should being with “#!/bin/bash”
  • Comments can be added by prefixing the line with #
We are going to write a simple program in our first script. Write below lines of code in a file and name it as sample1.sh
 
#!/bin/bash

x=10

echo $x

Before you execute above command, ensure that you modify the permission of the file sample1.sh so that you can execute it.
 
chmod +x sample1.sh

To execute this program, just go to the shell prompt and type ./sample1.sh This should generate below output.
10

Web development and Automation testing

solutions delivered!!