First Linux Script
In this first script I will show you all the details and preparations that you will need to do prior creating an running your first Linux script. I will use VIM text editor (see the tutorial in the link), but you can use any editor that you might like.
Go to the folder in which you want to create the file for the script and type:
vim test.sh
The editor will create a new file called test.sh (if the file already exist, it will be opened for editing), then input the following commands in the file:
#!/bin/sh echo “This is my first Linux script” echo “I will learn more advanced Linux scripts…” echo “… but a little bit later”
Save your script and exit editor.
Make sure that your file is allowed to run by running chmod command (see the permissions tutorials: File permissions in Linux and Permissions in Linux: Octal/Absolute mode):
chmod +x test.sh
Run the script file with:
./test.sh