How to write your first shell scriptzalam
Launch a terminal vi, nano or any other prefered editor of your choice. I will be using nano as a editor.
At the top type the following code #!/bin/bash. This is known as a Shebang line.
#!/bin/bash echo "start of script" ls echo "end of script"
This script prints a header line then list directories and a footer message in script.
Now to come out of the nano editor, press escape and save changes.
Now we need to make this Shell Script, executable. To do this, enter the following command
chmod +x /home/bash-scripts/my-first-script.sh
To run this Shell Script, simply type
You should get the list of directories