dipanjal / Journey_Of_Bash_Scripting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Journey_Of_Bash_Scripting

How to run a bash script file?

  • One time process only: If you are a linux user, first check where you bash exists. Open the terminal (press CRTL+T) and execute the command: which bash. It will show you the dirctroy where bash exists. In my case it gives the output: /usr/bin/bash.
  • Cloning the project: In the terminal, execute the command: git clone https://github.com/shshetudev/Journey_Of_Bash_Scripting.git
  • Forking the project: You can also Fork the project if you want. Just click the fork button on the upper right hand side.
  • Creating file: I am considering the first example: 1_Hello_World.sh of my folder: 30 Bash Scripting Example. In the terminal execute nano 1_Hello_World.sh. It will create our desired bash script file.
  • Writing and Saving the file: In the console, we write : #!/bin/bash. It is kind of preprocessor command to run any script. Here #! is read as She bangs or Hash bang. Then we write: echo "Hello World". echo is a command to print the output. Just like "printf" in C or python. After writing upto this we save the code by pressing: CRTL+S. And we exit from the file by pressing: CRTL+X.
  • Executing file by "bash" command: Execute: bash 1_Hello_World.sh
  • Onther way of Executing script file: Execute: sudo chmod +x 1_Hello_World.sh. Then execute: ./1_Hello_World.sh

About


Languages

Language:Shell 100.0%