JoseManimala/Notes

From FedoraProject

Jump to: navigation, search

Shell Script Basics

A shell is an access point to your operating system and kernel(heart of the OS!!). Any command that is typed in this screen is a shell command. Now a shell script is a set of shell commands put into a file so that they can be run together. This process is called batch processing.

Use any editor you have. Save the file as anything you want but the standard method is to save the file as <filename>.sh for shell-script. Now type the commands in making sure that only one command comes on one line.

To execute a shell script you can use the $exec <filename>.sh command or use the ./<filename>.sh command. If it says execute permission denied, you have to change the permissions. just type chmod u+x <filename>.sh. The command means allow user(u) to(+) execute(x)<filename>.sh

Using variables in shell scripts can be a little tricky. But here is a simple way $n = 10 stores the value 10 to n. $n = n+1 increments the value of n. Its very simple to do. $~ echo $n will print the value of n. storing string to variable is easy $ name='HELLO'.