25, May, 2019

Shell Scripting

shell script is small computer program that is designed to be run or executed by the Unix shell, which is a command-line interpreter. … The shell script is usually contained in a simple text file.

shell script is a computer program designed to be run by the Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to bescripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.

Why do we use shell scripting?

Shell scripts allow us to program commands in chains and have the system execute them as a scripted event, just like batch files. They also allow for far more useful functions, such as command substitution. You can invoke a command, like date, and use it’s output as part of a file-naming scheme.

Steps to write and execute a script

  1. Open the terminal. Go to the directory where you want to create your script.
  2. Create a file with .sh extension.
  3. Write the script in the file using an editor.
  4. Make the script executable with command chmod +x <fileName>.
  5. Run the script using ./<fileName>.
Call Now Button