Shell Scripting concepts

๐Ÿ‘‰ What is shell scripting?

Combining multiple commands in single file and then running that file using shell to automate our use-case is shell scripting.

๐Ÿ‘‰ Introduction of operating system interfaces

Types of operating system interface :-
i) CLI, ii) GUI.

๐Ÿ‘‰ What is the command-line interface?

It is an interface where we instruct the OS by giving the commands on a black screen i.e. shell.

๐Ÿ‘‰ What is the shell?

Shell is a program that is primarily present in every OS and is written in some language like BASH/C/SH.

๐Ÿ‘‰ What is bash shell?

Bash is a shell program that helps to execute the script or programs, bash is an updated version of the sh shell.

๐Ÿ‘‰ What is a variable? and its type?

Variables are use to store the data. Types of variable :-
i) pre-defined variable
ii) user defined variable
iii) environment variable.

๐Ÿ‘‰ What is an exit code?

When we run any command they throw number which specifies that whether the command ran or executed successfully or not. This number is called as exit code.

๐Ÿ‘‰ What is the script?

List of command in proper sequence written in the file is script.

๐Ÿ‘‰ Difference between command and script

Script is group of command in file use to automate our task whereas command is use to execute particular task manually.

๐Ÿ‘‰ What is the use of hashbang /shebang

Hashbang/shebang is use to define which shell you are using whether it is sh, bash, etc.

๐Ÿ‘‰ How to parameterize the script?

We can parameterize by using parameterized arguments $1,$2,etc .

๐Ÿ‘‰ Describe โ€˜awkโ€™ command.

Awk is mostly used for pattern scanning and processing. It searches one or more files to see if they contain lines that matches with the specified patterns.

๐Ÿ‘‰ Describe โ€˜watchโ€™ command?

Watch command is use to monitor program/ output of another command continuously.

๐Ÿ‘‰ Write the command for getting the total number of false client hits.

โ€œawk โ€˜$9==404 {print $0}โ€™ access_log | sort | uniq | wc -lโ€ is the command for getting the total number of false client hits.

๐Ÿ‘‰ tail command is used for?

โ€˜tailโ€™ command is used to get the output of last 10 commands of a file. -n <number> option can be given to change no of lines.

๐Ÿ‘‰How to get filter dd:mm:yy from date output?

To get filter dd:mm:yy from the date output, we use the command:- date +%e:%b:%G.

๐Ÿ‘‰ How to run multiple commands altogether?

To run multiple commands in a single line, we can separate the commands by โ€œ;โ€ or โ€œ&&โ€ or โ€œ||โ€ depending upon the use case.

๐Ÿ‘‰ Write the command to create multiple files without redundancy.

To create n files without redundancy we use the command:- touch a{1โ€ฆ.n}.txt

๐Ÿ‘‰What are the different options available for awk command and their purpose?

The different options available for the awk command are:-
->-F :- Used for specifying the delimiter.
->END:- Used for getting the last line of the output produced by the awk.
->NF:- Used to display the total number of fields in unsorted data.
->NR:- Used to display the row number of each row.

๐Ÿ‘‰How to create function in shell script?

To create function in shell scripting, we follow the syntax:- โ€œ function_name() { body; } โ€.




2x Red Hat Certified | Aspiring DevOps Engineer | Aviatrix Certified Engineer| AWS | Ansible | Openshift | Docker | Kubernetes

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Beginnerโ€™s Guide To Optimizing Julia Code

The Bootcamp Sabbatical (Part 2)

How do Story Points help you measure your development speed?

Memory Protection Unit

Gradle 102: Gradle Basics

An Overview of spaCyโ€™s Token Matcher and Phrase Matcher

Python Environment for Data Science Beginners

Weather Station Server using ESP32 and Sensors (DHT11/BME280)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bhavesh S. Sonewale

Bhavesh S. Sonewale

2x Red Hat Certified | Aspiring DevOps Engineer | Aviatrix Certified Engineer| AWS | Ansible | Openshift | Docker | Kubernetes

More from Medium

Python Comprehensions

Mastering Python for Beginners using PyCharm and saving on GitHubโ€Šโ€”โ€ŠCreating a Github Repository

Getting Started with Linux For Beginners


How to check the version before installing a package using apt-get?