Version 6 (modified by 2 years ago) ( diff ) | ,
---|
Hands-On ¶
Linux programming (scripting) ¶
Shell Scripting is the language of the linux terminal. Shell scripts are sometimes referred to as “shebang” which is derived from the “#!” notation. Shell scripts are executed by interpreters present in the linux kernel. Interpreters include: bash, csh, zsh e.t.c. Most popular of which is bash.
Typical operations performed by shell scripts include file manipulation, program execution, and printing text.
How to Write Shell Script in Linux/Unix
- Create a file using a vi editor(or any other editor). Name script file with extension . sh.
- Start the script with #! /bin/sh.
- Write some code.
- Save the script file as filename.sh.
- For executing the script type bash filename.sh.
Github administration ¶
Creating a repository
Create a project directory and cd into it. Execute the following git command from the directory to create a git repository.
git init
Checking out a repository ¶
You can create a copy of your git repository using the clone command. Execute the following command to clone your project directory.
git clone /path/to/project-repository
Every git repository has three trees. A working directory, Index and Head. ==== ¶
- Working directory: It contains the actual project files.
- Index: It is the staging area where you add the project files that needs to be committed.
- Head: Head is where the reference to you previous commit exists.
Adding file to the staging area: (add) ¶
git add <filename>
Let’s say you want to add all the files in your project directory to the staging area. Execute the following command to do the same
git add --all
Committing new changes to the repository (commit): ¶
Once you have added all the files to the staging area, you can commit the changes with a reference message using the “-m” flag as shown below.
git commit -m “my first commit”