Shell-Scripting Workshop

Aman Goyal
3 min readApr 27, 2021

Self Reflection

Such a wonderful workshop Conducted by Mr. Vimal daga sir and Linux world. There was a lot to learn in these 2 days . Here is the brief of the content that i learned

day 1:-

1. Shell scripting is one of the scripting languages and a native automation tool where we can automate simple things in our systems.

2. we generally use two types of interfaces such as CLI(command line interface) and GUI (graphical user interface) in the operating system.

3. It is an interface where we instruct the OS by giving the commands on a terminal.

4. The program running behind CLI that takes input and provides output is called a shell.

5. Bash is the default shell in Linux operating system, there are different types of shell present in different Linux distributions.

6. variables are used to store the location of values in memory, there are many types of variable like (Environmental, positional, user-defined, per-defined)

7. Exit code is the code that represents the execution status of the command, where it executed successfully or not i.e. if the output is success gives 0 otherwise false-> 1.

8. Script is the document that has content to be performed in a procedural pattern and has written a program in it with commands.

9. Command is single instruction performing something whereas script is a series of commands.

10. “#!” is called Shebang, when we run the file os will know which shell to use.

11. Positional parameters $1,$2 are used to parameterize the script.

12. We can take input in the shell with the help of the [read] command.

13. I/0 Redirection is used to redirect input and output of a command or script using > or < operators.

14. While loop is used to repeat a section of code a number of times until a certain condition is matched.

15. To cut any field from any file: cut -f <fieldnum> -d <separator> <file>

16. Command to add timestamp date +%e/%b/%G

Day2:-

1) The ‘awk’ command is used for searching one or more files and after search is complete it will print the output.

2) The ‘watch’ command is used to execute command after time period time.

3) The command to get total no. of false client hits is:

“ awk ‘$9==404 { print $1 }’ access_log | sort | uniq | wc -l “

4) The ‘tail’ command is used to get output of last 10 commands of a file.

5) To get filter output from date dd:mm:yy by following command:

‘date+ %e:%b:%G’

6) To run multiple commands ,that time we can separate the commands by “:” or “&&” or “||” depending upon the use cases.

7) The command to create multiple files without redundancy is:

‘touch a{1…n}.txt’

The ‘awk’ command is used to perform arithmetic and logical operations and also used in conditional looping.

9) To sort and count the line log file , sort and unique command is used .

10) To create functions in Shell Scripting:

Eg., linux() {echo “Linux”}

11)Functions can have different commands in it and can be called anywhere.

12) By using ‘-stdin’ , we can pass the value to the command which requires value on run time.

13) The command to search a specific pattern is:

“ark’/prince/{print}’ /file/path”.

14) The ‘sed’ command is used for searching data, insert data and replace data.

A very great experience and a lot to learn
Thank you Vimal daga sir and Preeti Ma’am for the wonderful workshop .

--

--