Shell Scripting Workshop

Chirag Agarwal
3 min readApr 27, 2021

On 24th and 25th of April I have attended an amazing workshop on Shell Scripting 🤩

The workshop was very informative, and completely hands-on. I came to know the uniqueness about the shell, its use cases and many operations, instructions and keywords through which we can create any sort of useful script.

Things that we have covered are:
💠 Advantages of shell scripting
💠 Basis of Bash
💠 awk command
💠 sed command
💠 comparison operations
💠 importance of scripts
💠 loops in shell
💠 remote execution of scripts.
💠 exit code, hashbang/shebang
💠 keywords like sort, uniq, wc etc.

Summary:

Day-1

✔Shell scripting is a way of automating the things in Which we can write all commands in a single file/script & run that script using a shell known as shell scripting

✔CLI is an interface to interact with OS using commands

✔Shell is a program that takes command from the user & print output on the console, there are many shells available like bash, etc

✔Variables are used to store the values in the shell. The variable stores the values till the session is in the process once the shell terminated the values are also erased from the memory

✔Two types of variables predefined & user-defined

✔The Exit code denotes whether the cmd is run successfully executed or not. Usually, if the cmd is the success it gives 0 else 1, but it also depends on the developer

✔The script is a set of commands provided to shell

✔The live interpreter

✔Migration operation is the process of transferring files from one system to another

✔I/O redirection changing the way from where commands read input to where commands send output. Redirection can be into a file (‘<’, ‘>’) or a program

✔To take input in the shell we can use the read keywords, we can read dynamic data from the end-user.

Day-2

✔The awk command is used for data and text processing and generating reports. It is mostly used for pattern scanning and processing

✔Watch cmd is used for continuous monitoring, this will continuously refresh the command every two seconds and display it

✔Tail command shows the last 10 records from the file

✔We can use the special character in the date command to get the output of the date in any format we want. Eg: date +%e:%b:%G for dd:mm:yy

✔To run multiple commands together we can use the logical operators like && as and, || as or between the two commands.

✔Functions in shell script syntax i.e function_name(){statement}

✔Pipe ‘|’ gives the output of one command to another command

✔ touch file _{1..n}.<exention> command is used to create multiple files without redundancy

✔To sort the data command is sort, for counting the lines in the file we have the command, wc -l <filename>

✔ We can search specific pattern using the awk command using the regex pattern while specifying the option

✔Using sed(stream editor) we can do multiple operations like insertion, deletion, searching, etc.

--

--