To create one use the .sh extension but it doesn't really matter but it helps future users to quickly determine which file type it is. The bat name is mostly used on Windows but in Linux file name extensions do not really matter. Meaning I can call my file say run.de and it would still run in bash file but I believe it's a good practice to name them with the .sh file extension.
For the editor, part uses any that is best for you between nano vim gedit emacs, but I believe gedit would be nice to start with.
In linux they are bash scripts. You can use most any editor and you can call it what you wish, Linux does not use extensions such as .sh or .bat or .exe to .doc to identify files, it uses magic.
Probably gedit for a graphical editor and nano from the command line.
Avoid word processors such as libre office as they add headers you don't want.
To create one use the
.sh
extension but it doesn't really matter but it helps future users to quickly determine which file type it is. Thebat
name is mostly used on Windows but in Linux file name extensions do not really matter. Meaning I can call my file sayrun.de
and it would still run inbash
file but I believe it's a good practice to name them with the.sh
file extension.For the editor, part uses any that is best for you between
nano vim gedit emacs
, but I believegedit
would be nice to start with.How to:
using
gedit
text editor:Create the file:
Add code into file:
Make file executable:
Run the file from terminal:
In linux they are bash scripts. You can use most any editor and you can call it what you wish, Linux does not use extensions such as .sh or .bat or .exe to .doc to identify files, it uses magic.
Probably gedit for a graphical editor and nano from the command line.
Avoid word processors such as libre office as they add headers you don't want.
http://www.linfo.org/magic_number.html
To write a bash script , start the file with a "SheBang" or #!/bin/bash
Tons of tutorials on the web - https://linuxconfig.org/bash-scripting-tutorial
Batch file equivalent in linux is shell script (.sh). You can use gedit, vim or any other text editor available to create one.
A good start for begginers is http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html.
Hope this helps :)