{"id":30883,"date":"2023-01-04T16:19:22","date_gmt":"2023-01-04T10:49:22","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/"},"modified":"2024-11-18T13:57:33","modified_gmt":"2024-11-18T08:27:33","slug":"shell-scripting-interview-questions","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/","title":{"rendered":"Top 70+ Shell Scripting Interview Questions &amp; Answers"},"content":{"rendered":"\n<p>Shell scripts are programs that contain commands to be executed by a shell, which is a command-line interpreter. Long repetitive series of commands are compiled into a single script, thereby largely reducing repetitive work. Shell scripts are used for program execution, file manipulation, and printing text. One of the common uses of shell scripting is to program operating systems of UNIX, Windows, Apple, etc. When it comes to system level operations, shell scripting is considered as one of the easiest programming languages. <\/p>\n\n\n\n<p>The first shell was developed by Ken Thompson for UNIX in 1971. In 1977, Bourne shell was created by Stephen Bourne at bell labs for UNIX. It is a useful shell today. In some Linux systems, it is a default shell. Tenex C shell Korn shell, the Bourne-again shell, exotic shell are the different types of shell. Through this blog, we will learn the top shell scripting interview questions and answers that will help you land your dream job. <\/p>\n\n\n\n<p>Let's get started. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"basic-shell-scripting-interview-questions\">Basic <strong>Shell Scripting Interview Questions<\/strong><\/h2>\n\n\n\n<p>This section of the blog covers the basic shell scripting interview questions and answers required for you to kick-start your journey. If you are a experienced professional, you can use these questions to revise your knowledge. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-what-is-linux\"><strong>1. What is Linux?<\/strong><\/h3>\n\n\n\n<p>It is a family of <strong>open-source<\/strong> Unix operating systems based on the <a href=\"https:\/\/www.mygreatlearning.com\/blog\/linux-tutorial\/\" target=\"_blank\" rel=\"noreferrer noopener\">Linux kernel<\/a>.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-difference-between-linux-and-unix\"><strong>2. Difference between Linux and Unix?<\/strong><\/h3>\n\n\n\n<p><strong>Linux<\/strong>&nbsp;is a clone of&nbsp;<strong>Unix<\/strong>.&nbsp;<strong>Linux<\/strong>&nbsp;default shell is BASH (Bourne Again Shell) while the&nbsp;<strong>Unix<\/strong>&nbsp;shell is Bourne Shell.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-what-is-a-kernel\"><strong>3. What is a kernel?<\/strong><\/h3>\n\n\n\n<p>The kernel is a computer program at the core of a computer's operating system that manages operations of computer and hardware.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-what-is-an-interpreter\"><strong>4. What is an interpreter?<\/strong><\/h3>\n\n\n\n<p>Interpreter translates the program line by line into machine code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-what-is-a-compiler\"><strong>5. What is a compiler?<\/strong><\/h3>\n\n\n\n<p>Compiler scans the whole program and converts it into machine code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6-what-is-a-shell\"><strong>6. What is a shell?<\/strong><\/h3>\n\n\n\n<p>Shell is a program and command line interpreter. It is an interface between user and kernel.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"7-what-is-cli-and-gui\"><strong>7. What is CLI and GUI?<\/strong><\/h3>\n\n\n\n<p>CLI is a command line interface. This user interface enables the user to give commands to interact with the device.<\/p>\n\n\n\n<p>GUI is a graphical user interface. This user interface enables users to interact with devices with the help of graphical icons and visual indicators.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"8-why-would-we-use-cli-over-gui\"><strong>8. Why would we use CLI over GUI?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CLI gives better control to the user.&nbsp;<\/li>\n\n\n\n<li>CLI is a best&nbsp; option for professionals who work on more programming languages.<\/li>\n\n\n\n<li>It&nbsp; required less memory as compared to GUI.&nbsp;<\/li>\n\n\n\n<li>The speed of the CLI is faster than GUI.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9-what-is-shell-scripting\"><strong>9. What is shell scripting?<\/strong><\/h3>\n\n\n\n<p>It is a text file which contains list or series of command or statements to be executed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"10-what-is-the-default-login-shell-how-to-change-it\"><strong>10. What is the default login shell? How to change it?<\/strong><\/h3>\n\n\n\n<p><strong>\/bin\/bash<\/strong> is the default login shell. Using the command&nbsp; <strong>\u201cchsh\u201d<\/strong> we can change the default shell.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"11-what-is-the-importance-of-shell-scripting\"><strong>11. What is the importance of shell scripting?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you need to perform the same task repeatedly, you should use shell scripting&nbsp;<\/li>\n\n\n\n<li>By using shell scripting, you can make your own tools&nbsp;<\/li>\n\n\n\n<li>It is very useful for a system admin to automate daily tasks<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"12-what-are-the-various-stages-of-the-linux-process\"><strong>12. What are the various stages of the Linux process?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Waiting: <\/strong>The process waits for resources<\/li>\n\n\n\n<li><strong>Running:<\/strong> The process is currently being&nbsp; executed<\/li>\n\n\n\n<li><strong>Stop:<\/strong> The linux process stop after execution<\/li>\n\n\n\n<li><strong>Zombie: <\/strong>The process has stopped but it is still active in process table<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"13-what-is-the-main-difference-between-bash-and-dos\"><strong>13. What is the main difference between BASH and DOS?<\/strong><\/h3>\n\n\n\n<p>BASH commands are case sensitive but DOS commands are not case sensitive.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"14-what-are-the-components-of-linux\"><strong>14. What are the components of&nbsp; Linux?<\/strong><\/h3>\n\n\n\n<p>Kernels, shells, GUI, system utilities and application programs&nbsp; are components of Linux.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"15-what-is-a-root-user\"><strong>15. What is a root user?<\/strong><\/h3>\n\n\n\n<p>It is an admin user that allows you full control of your system.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"16-what-are-the-environmental-variables\"><strong>16. What are the environmental variables?<\/strong><\/h3>\n\n\n\n<p>Environmental variable control shell function as well as other Linux programs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"17-what-is-lilo\"><strong>17. What is LILO?<\/strong><\/h3>\n\n\n\n<p>LILO is a boot loader used in Linux .It is used to load the operating system into main memory to start its operation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"18-what-are-the-different-types-of-commonly-used-shells-on-a-linux-system\"><strong>18. What are the different types of commonly used shells on a Linux system?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Bash\/Bourne Again Shell<\/strong>: This is the most common shell available on all Linux and based systems. It is open source and freeware.<\/li>\n\n\n\n<li><strong>CSH or C Shell<\/strong>: This Shell scripting program uses the C programming\u2019s shell syntax and it's almost similar to C.<\/li>\n\n\n\n<li><strong>KSH or Korn Shell<\/strong>: Korn is a Unix based Shell scripting program, initially based on the Bash Shell Scripting. This shell is quite advanced and it's a high level programming language.<\/li>\n\n\n\n<li><strong>TCSH<\/strong>: There is no specific full form of TCSH. It is as it is. TCSH is an advanced version of Berkeley Unix C shell. It again supports C style syntax.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"19-which-command-is-used-to-execute-a-shell-file\"><strong>19. Which command is used to execute a shell file?<\/strong><\/h3>\n\n\n\n<p>First Set execute permission on your script using chmod command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>chmod +x script-name-here.sh<\/strong><\/code><\/pre>\n\n\n\n<p><strong>To run your script:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/script-name-here.sh<\/code><\/pre>\n\n\n\n<p><strong>Another option to execute shell script:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sh script-name-here.sh<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"20-name-of-editors-which-are-available-in-almost-all-unix\"><strong>20. Name of Editors which are available in almost all UNIX?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>vi\/vim&nbsp;<\/li>\n\n\n\n<li>Gedit <\/li>\n\n\n\n<li>VSCode<\/li>\n\n\n\n<li>Nano <\/li>\n\n\n\n<li>Sublime <\/li>\n\n\n\n<li>Atom <\/li>\n\n\n\n<li>GNU emacs<\/li>\n\n\n\n<li>Brackets <\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"intermediate-shell-scripting-interview-questions\"><strong>Intermediate Shell Scripting Interview Questions<\/strong><\/h2>\n\n\n\n<p>This section covers shell scripting interview questions for the intermediate level and will help you attend your upcoming interviews with confidence. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-what-is-interactive-and-non-interactive-shell\"><strong>1. What is interactive and non-interactive shell?<\/strong><\/h3>\n\n\n\n<p>Interactive Shell<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/bin\/bash and \/bin\/sh <\/code><\/pre>\n\n\n\n<p>Non-interactive shell<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/sbin\/nologin <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-what-is-the-absolute-and-relative-path\"><strong>2. What is the absolute and relative path?<\/strong><\/h3>\n\n\n\n<p><strong>Absolute path<\/strong> is the full path of the directory. It always starts with \u201c\/\u201d .<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd&nbsp; \/var\/tmp\/abrt\/<\/code><\/pre>\n\n\n\n<p><strong>Relative path<\/strong> is necessary from current location to reach particular directory doesn\u2019t start with \u201c\/\u201d.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd .. , &nbsp; cd \u2013<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-how-to-create-read-and-delete-files\"><strong>3. How to create, read and delete files?<\/strong><\/h3>\n\n\n\n<p>The touch command is used for creating files.<br>Example: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#touch filename&nbsp;<\/code><\/pre>\n\n\n\n<p>The cat command is used for reading files. <br>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#cat filename<\/code><\/pre>\n\n\n\n<p>The rm command is used&nbsp; for delete a file.<br>Example: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#rm \u2013f&nbsp; filename&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-how-to-create-and-delete-a-directory\"><strong>4. How to create and delete a directory?<\/strong><\/h3>\n\n\n\n<p>The mkdir command is used for creating a directory.&nbsp; <br>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># mkdir filename<\/code><\/pre>\n\n\n\n<p>The rmdir command is used for remove directory&nbsp; <br>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#rmdir filename&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-how-to-create-multiple-text-files-and-directories\"><strong>5. How to create multiple text files and directories?<\/strong><\/h3>\n\n\n\n<p>To create multiple text file touch file name {} command is used.&nbsp;<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>Suppose we want create 4 files then we type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#touch filename{1..4}<\/code><\/pre>\n\n\n\n<p>To create multiple directory mkdir filename {} command is used.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>Suppose we want to create 4 directory, then we type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir filename {1..4}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6-what-is-the-use-of-head-and-tail-command\"><strong>6. What is the use of head and tail command?<\/strong><\/h3>\n\n\n\n<p>Head command is used for display started 10 lines<\/p>\n\n\n\n<p>Tail command is used for display started 10 lines<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"7-how-to-find-the-current-shell-which-you-are-using\"><strong>7<\/strong>. <strong>How to find the current shell which you are using?<\/strong><\/h3>\n\n\n\n<p><strong>$echo $SHELL<\/strong> command is used for find current shell.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"8-how-to-find-an-available-shell-in-your-system\"><strong>8<\/strong>. <strong>How to find an available shell in your system?<\/strong><\/h3>\n\n\n\n<p><strong>Cat \/etc\/shells<\/strong> command is used to find available shells in your system.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9-how-to-create-shortcuts-in-linux\"><strong>9.\u00a0How to create shortcuts in Linux?<\/strong><\/h3>\n\n\n\n<p>To create shortcut <strong>\u201clink\u201d<\/strong> command use. <\/p>\n\n\n\n<p>There are two types of link: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Hard link <\/li>\n\n\n\n<li>Soft link<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"10-tell-me-the-difference-between-hard-link-and-soft-link\"><strong>10. Tell me the difference between hard link and soft link?<\/strong><\/h3>\n\n\n\n<p>Deleting the original file does not affect the hard link but Deleting the original file makes the soft link inactive.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"11-how-will-you-pass-and-access-arguments-to-a-script-in-linux\"><strong>11. How will you pass and access arguments to a script in Linux?<\/strong><\/h3>\n\n\n\n<p>For pass arguments in script <strong>\u201cscriptname arg1 arg2 arg3 \u2026\u201d&nbsp;<\/strong><\/p>\n\n\n\n<p>For access arguments in script can be accessed inside the script as <strong>\u201c$1 , $2 .. $n\u201d<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"12-what-is-the-significance-of\"><strong>12. What is the significance of $#?<\/strong><\/h3>\n\n\n\n<p>It represents the total number of arguments passed by string.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"13-what-is-the-difference-between-and\"><strong>13. What is the difference between $* and $@?<\/strong><\/h3>\n\n\n\n<p><strong>$*<\/strong> consider the entire set of positional parameters as a single string, but&nbsp;<strong>$@<\/strong> treat each quoted argument as a separate argument.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"14-explain-s-permission-bit-in-a-file\"><strong>14. Explain \"s\" permission bit in a file?<\/strong>\u00a0<\/h3>\n\n\n\n<p>\u201cs\u201d bit also called \u201cset user id\u201d(SUID) bit. \u201cs\u201d on file causes the process to have the privileges of the owner of the file during the instance of the program.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"15-what-are-the-different-types-of-variables-used-in-shell-script\"><strong>15. What are the different types of variables used in Shell Script?<\/strong><\/h3>\n\n\n\n<p><strong>System defined variable<\/strong>: System defined variable created by os itself. These variables are generally defined in capital letters. It can be viewed by the \u201cset\u201d command.<\/p>\n\n\n\n<p><strong>User defined variable<\/strong>: It created by system users. Value of variable can be view by using \u201cecho $variablename\u201d command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"16-what-is-the-difference-between-and\"><strong>16. What is the difference between = and ==?<\/strong><\/h3>\n\n\n\n<p><strong>=&nbsp;<\/strong>is used for assigning value to a variable. <\/p>\n\n\n\n<p><strong>== <\/strong>is used for string comparison.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"17-what-is-the-use-of-a-pipe-operator-how-to-execute-multiple-commands-in-one-line\"><strong>17. What is the use of a pipe operator? How to execute multiple commands in one line?<\/strong><\/h3>\n\n\n\n<p>The pipe operator is used for one by one execution of command but commands should not be dependent on each other.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"18-what-are-the-different-modes-of-vi-editors\"><strong>18. What are the different modes of vi editors?<\/strong><\/h3>\n\n\n\n<p><strong>Command mode<\/strong>: this is a mode where you start<\/p>\n\n\n\n<p><strong>Edit mode<\/strong>: This mode allows you to do next editing.<\/p>\n\n\n\n<p><strong>Ex mode<\/strong>: In this mode you interact with vi with instruction to process<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"19-what-is-redirection\"><strong>19. What is redirection?<\/strong><\/h3>\n\n\n\n<p>Redirection is the process of direction data from one output to another.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"20-how-to-find-the-status-of-the-process\"><strong>20. How to find the status of the process?<\/strong><\/h3>\n\n\n\n<p>Ps ux command user for find status of process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"21-how-to-check-memory-status\"><strong>21. How to check memory status?<\/strong><\/h3>\n\n\n\n<p>Free command is useful for checking memory status.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"22-how-to-debug-a-shell-script\"><strong>22. How to debug a shell script?<\/strong><\/h3>\n\n\n\n<p>To debug a shell script we execute the script with the \u201c-x\u201d or \u201c-nv\u201d&nbsp; option.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"23-which-command-is-used-for-comparing-the-string-in-the-shell-script\"><strong>23. Which command is used for comparing the string in the shell script?<\/strong><\/h3>\n\n\n\n<p>To compare the string \u201ctest\u201d command is used.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"24-what-is-the-difference-between-and\"><strong>24. What is the difference between $! and $$?<\/strong><\/h3>\n\n\n\n<p><strong>$!<\/strong> Shows process id of the process that recently went into background&nbsp;<\/p>\n\n\n\n<p><strong>$$<\/strong>&nbsp; gives the process id of the currently executing process<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"25-which-command-is-used-to-find-all-information-of-the-user\"><strong>25. Which command is used to find all information of the user?<\/strong><\/h3>\n\n\n\n<p>\u201cfinger\u201d command shows all information of users.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"26-which-four-fundamental-components-of-every-file-system\"><strong>26. Which four fundamental components of every file system?<\/strong><\/h3>\n\n\n\n<p><strong>Boot block<\/strong>: It contains a small program called MBR which loads the kernel during system boot up.<\/p>\n\n\n\n<p><strong>Super block<\/strong>: Super block contains all information about the file system.<\/p>\n\n\n\n<p><strong>Inode block<\/strong>: It contains inode for every file of the file system.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"27-what-is-the-crontab\"><strong>27. What is the Crontab?<\/strong><\/h3>\n\n\n\n<p>Crontab stands for <em>cron table<\/em> because it uses the job scheduler <em>cron <\/em>to execute tasks.&nbsp;The&nbsp;crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"28-how-many-fields-are-present-in-a-crontab-file\"><strong>28. How many fields are present in a crontab file?<\/strong><\/h3>\n\n\n\n<p>The<strong> five fields<\/strong> contain information on <em>when to execute the command<\/em>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>minute(0-59)<\/li>\n\n\n\n<li>hour(0-23)<\/li>\n\n\n\n<li>day(1-31)&nbsp;<\/li>\n\n\n\n<li>month(1-12)<\/li>\n\n\n\n<li>day of the week(0-6, Sunday = 0).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"29-what-are-the-two-files-of-crontab-command\"><strong>29. What are the two files of crontab command?<\/strong><\/h3>\n\n\n\n<p><strong>cron.allow <\/strong>which decides the users need to be <em>permitted<\/em> for using the <strong>crontab command<\/strong>.<\/p>\n\n\n\n<p><strong>cron.deny <\/strong>which decides the users need to be <em>prevented<\/em> from using the <strong>crontab command<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"30-what-are-the-different-commands-available-to-check-the-disk-usage\"><strong>30. What are the different commands available to check the disk usage?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>df:<\/strong> It is used to check the free disk space.<\/li>\n\n\n\n<li><strong>du:<\/strong> It is used to check the directory wise disk usage.<\/li>\n\n\n\n<li><strong>dfspace:<\/strong> It is used to check the free disk space in terms of MB.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"31-how-to-open-a-read-only-file-in-the-shell\"><strong>31.\u00a0 How to open a read-only file in the Shell?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \u2013R &lt;Filename&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"32-how-to-find-out-how-long-the-system-has-been-running\"><strong>32<\/strong>. <strong>How to find out how long the system has been running?<\/strong>\u00a0<\/h3>\n\n\n\n<p>By using the command <strong>\"uptime\".<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"33-how-to-connect-to-a-remote-server-and-execute-some-commands\"><strong>33. How\u00a0to connect to a remote server and execute some commands?<\/strong><\/h3>\n\n\n\n<p>We can use ssh to do this:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh username@serverIP -p sshport&nbsp;<\/code><\/pre>\n\n\n\n<p>Once the above command is executed, enter the password.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"34-how-to-connect-to-a-database-server-from-linux\"><strong>34<\/strong>. <strong>How to connect to a database server from Linux?<\/strong>\u00a0<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql \u2013S serverName \u2013U username \u2013P password<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"35-how-can-i-set-the-default-permission-to-all-users-on-every-file-which-is-created-in-the-current-shell\"><strong>35<\/strong>. <strong>How can I set the default permission to all users on every file which is created in the current shell?<\/strong>\u00a0<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>umask 777<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"36-how-will-i-insert-a-line-abcd-at-every-50th-line-of-a-file\"><strong>36<\/strong>.<strong> How will I insert a line \"ABCD\" at every 50<sup>th<\/sup> line of a file?<\/strong>\u00a0<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sed&nbsp; '50i\\ABCD' filename&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"37-how-to-find-the-total-disk-space-used-by-a-specific-user\"><strong>37.<\/strong> <strong>How to find the total disk space used by a specific user?<\/strong>\u00a0<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>du -s \/home\/username&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"38-how-to-print-the-login-names-of-all-users-on-a-system\"><strong>38<\/strong>. <strong>How to print the login names of all users on a system?<\/strong>\u00a0<\/h3>\n\n\n\n<p><strong>\/etc\/shadow<\/strong> file has all the users listed.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>awk \u2013F ':' '{print $1}' \/etc\/shadow|uniq \u2013u<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"39-write-a-shell-script-to-get-current-date-time-username-and-current-working-directory\"><strong>39.\u00a0Write a shell script to get current date, time, username and current working directory.<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><em>#!\/bin\/sh<\/em>\n<em>echo \"Hello, $LOGNAME\"<\/em>\n<em>echo \"Today's date is `date`\"<\/em>\n<em>echo \"Username is `who i am`\"<\/em>\n<em>echo \"Current directory is `pwd`\"<\/em><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"40-how-to-check-if-a-directory-exists\"><strong>40. How to check if a directory exists?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/sh\nif &#91; -d $mydir ]\nthen\necho \"Directory exists\"\nfi<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"41-explain-the-file-permissions\"><strong>41. Explain the file permissions.<\/strong><\/h3>\n\n\n\n<p>r - read 4<\/p>\n\n\n\n<p>w - write 2<\/p>\n\n\n\n<p>e - execute 1<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"42-given-a-file-replace-all-occurrence-of-word-abc-with-def-from-10th-line-till-end-in-only-those-lines-that-contains-word-mno\"><strong>42<\/strong>. <strong>Given a file, replace all occurrence of word \"ABC\" with \"DEF\" from 10<sup>th<\/sup> line till end in only those lines that contains word \"MNO\"\u00a0<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sed \u2013n '10,$p' file1|sed '\/MNO\/s\/ABC\/DEF\/'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"43-how-will-you-find-the-19th-line-of-a-file-using-only-tail-and-head-command\"><strong>43. How will you find the 19<sup>th<\/sup> line of a file using only tail and head command?\u00a0<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>tail +19 file1|head -1&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"44-how-to-use-the-sed-command-to-replace-the-content-of-the-file\"><strong>44. How to Use the sed command to replace the content of the file?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>if cat fille\nABCD\nEFGH\nThen O\/p should be \nEFGH\nABCD \n\nsed '1! G; h;$!d' file1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"45-i-want-to-create-a-directory-such-that-anyone-in-the-group-can-create-a-file-and-access-any-persons-file-in-it-but-none-should-be-able-to-delete-a-file-other-than-the-one-created-by-himself\"><strong>45.\u00a0I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.<\/strong>\u00a0<\/h3>\n\n\n\n<p>We can create the directory giving read and execute access to everyone in the group and setting its sticky bit \"t\" on as follows:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir direc1\nchmod g+wx direc1\nchmod +t direc1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"46-how-to-get-the-3rd-element-column-from-each-line-from-a-file\"><strong>46. How to get the 3rd element\/column from each line from a file?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/sh\nawk '{print $<em>3}' $1<\/em><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"47-write-down-the-syntax-for-all-the-loops-in-shell-scripting\"><strong>47. Write down the Syntax for all the loops in Shell Scripting.<\/strong><\/h3>\n\n\n\n<p><strong>For Loop:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for var in word1 word2 ... wordn\ndo\nStatement(s) to be executed for every word.\ndone<\/code><\/pre>\n\n\n\n<p><strong>While Loop:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while command\ndo\nStatement(s) to be executed if command is true\nDone<\/code><\/pre>\n\n\n\n<p><strong>Until Loop:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>until command\ndo\nStatement(s) to be executed until command is true\ndone<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"48-how-to-pass-arguments-to-a-script\"><strong>48. How to pass arguments to a script?<\/strong><\/h3>\n\n\n\n<p>.\/script argument&nbsp; used for passed argument to a script.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/script.sh  file.txt\ncat script.sh\n#!bin\/bash\nCat $1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"49-how-to-use-arguments-in-the-script\"><strong>49. How to use arguments in the script?<\/strong><\/h3>\n\n\n\n<p>In the script we use first argument as $1 and second argument as $2&nbsp;<\/p>\n\n\n\n<p>Example: To move file one destination($1) to another($2)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/move.sh file.txt \/text\ncat move.sh\n#!\/bin\/bash\nmv $1 $2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"50-how-to-get-5rd-element-from-each-line-from-the-file\"><strong>50. How to get 5<sup>rd<\/sup> element from each line from the file?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>awk \u2018{print $5}\u2019<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"51-how-to-find-process-name-from-process-id\"><strong>51. how to find process name from process ID?<\/strong><\/h3>\n\n\n\n<p><strong>\u201cps \u2013p pid\u201d<\/strong> command used to find the process name.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"52-how-to-create-alias-command-in-shell\"><strong>52. How to create alias command in shell?<\/strong><\/h3>\n\n\n\n<p>Alias name = \u201dcommand whose alias to be created\u201d.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"53-what-is-the-c-and-b-permission-field-of-the-file\"><strong>53 . What is the c and b permission field of the file?<\/strong><\/h3>\n\n\n\n<p>C specifies whether the file is character special file or block special file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"54-how-to-get-5rd-element-from-each-line-from-the-file\"><strong>54. How to get 5<sup>rd<\/sup> element from each line from the file?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>awk \u2018{print $5}\u2019<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"55-what-is-the-use-of-a-shebang-line\"><strong>55. What is the use of a shebang line?<\/strong><\/h3>\n\n\n\n<p>Shebang line at the top of each script determines the location of the engine which is to be used in order to execute the script.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"56-how-to-add-two-strings\"><strong>56. How to add two strings?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>S1=\u201dhello\u201d\nS2=\u201dworld\u201d\nLet s3=$s1+$s2\nEcho $s3<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"57-how-to-add-two-integers\"><strong>57. How to add two integers?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Int1=3\nInt2=2\nInt3=$int1+$int2\nEcho $int3<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"58-write-a-script-to-check-if-a-file-exists-on-the-system\"><strong>58. Write a script to check if a file exists on the system?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>If &#91;-f \/var\/www\/html]\nThen \nEcho \u201cfile exists\u201d\nFi<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"59-why-bin-sh-or-bin-bash-at-the-beginning-of-every-script\"><strong>59. Why #!\/bin\/sh or #!\/bin\/bash at the beginning of every script?<\/strong><\/h3>\n\n\n\n<p>That line tells which shell to use.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"60-from-given-file-name-find-the-count-of-lines-containing-word-abc\"><strong>60. From given file name find the count of lines containing word\u00a0 \u201cABC\u201d<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>grep \u2013c \u201cABC\u201d filename<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"61-what-would-be-the-output-of-command-echo-new-variable\"><strong>61. What would be the output of command: echo ${new:-variable}<\/strong><\/h3>\n\n\n\n<p>Output: <strong>variable&nbsp;<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"62-how-to-print-all-array-indexes\"><strong>62. How to print all array indexes?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>echo ${!array&#91;@]} used to print all array indexes.<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"63-how-to-remove-elements-from-an-array-with-id-3\"><strong>63. How to remove elements from an array with id 3?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Unset array&#91;3]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"64-write-a-script-to-compare-numbers\"><strong>64. Write a script to compare numbers?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\nX=10\nY=20\nIf &#91; $x \u2013gt $y ]\nThen \nEcho \u201c x is greater than y\u201d\nElse \nEcho \u201cy is greater than x\u201d\nFi<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"65-what-are-the-types-of-permission-at-the-file-level-in-shell\"><strong>65. What are the types of permission at the file level in Shell?<\/strong><\/h3>\n\n\n\n<p><strong>Owner permissions<\/strong>: The permissions granted to a user with all the rights at the root level.<\/p>\n\n\n\n<p><strong>Group permissions<\/strong>: The permissions granted to a user with all the rights in a particular group.<\/p>\n\n\n\n<p><strong>Other&nbsp; permissions<\/strong>: The permissions granted to a user with all the rights globally to a file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"66-how-to-use-comments-in-shell-scripting\"><strong>66. How\u00a0 to use comments in shell scripting?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash\n# addition\n((sum=30+20))\n#print\nEcho$sum<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"67-how-to-use-multi-line-comments-in-shell-scripting\"><strong>67. How to use multi-line comments in shell scripting?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash\n: \u2018\nThis script calculates squares of 8.\n\u2018\n((square=8*8))\necho $area<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"68-write-a-script-that-receive-input-from-user\"><strong>68. Write a script that receive input from user.<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash\nEcho  \u2013n  \u201center input:\u201d\nread input\necho \u201c you entered: $input\u201d<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"69-write-a-script-using-the-and-operator\"><strong>69.<\/strong> <strong>Write a script using the AND operator.<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash\nEcho \u2013n \u201center number:\u201d\nread number\nif  &#91;&#91; ($number  \u2013lt 10 )  &amp;&amp; ($number%2  \u2013eq  0)]]\necho  \u201ceven number\u201d\nelse \necho \u201codd number\u201d\nfi<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"70-write-an-example-of-or-operator\"><strong>70.<\/strong> <strong>Write an example of OR operator.<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash\nEcho \u2013n \u201center any number : \u201c\nread n\nif  &#91;&#91; ( $n \u2013eq 10 || $n  -eq 45) ]]\nthen \necho \u201c you win\u201d\n\nelse  \u201c you lost!\u201d\nfi\nexample of elif \n#! \/bin\/bash\nEcho \u2013n \u201center number :\u201d\nread number \nif  &#91;&#91; $number  -gt 10]]\nthen \necho \u201cnumber  is greater than 10\u201d\nelif  &#91;&#91; $num \u2013eq 10 ]]\nthen \necho \u2018number is equal to 10\u201d\nelse \necho \u201c number  is less than 10\u201d\nfi<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"71-write-a-script-for-adding-multiple-values\"><strong>71. Write a script for adding multiple values.<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash\nSum=0\nFor (( counter=1 ; counter&lt;5 ;counter++))\nDo\nEcho \u2013n \u201center your number\u201d\nread n\n(( sum+=n))\n#echo \u2013n \u201c$counter\u201d\nDone \nPrintf   \u201c\\n\u201d\necho  \u201cresult is : $ sum\u201d<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"72-write-an-example-of-a-function\"><strong>72. Write an example of a function.<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash \nFunction Add()\n{\necho  \u2013n \u201center number:\u201d\nread a\necho  \u2013n  \u201center 2nd number :\u201d\nread b\necho \u201caddition  is: $((  a+b ))\u201d\n}\nAdd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"73-how-to-send-mail-using-shell-script\"><strong>73. How to send mail using shell script?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash\nRecipientadmin@example.com\nSubject=\u201dscript\u201d\nMessage=\u201dthis mail send by script\u201d\n\u2018mail \u2013s $subject $recipient &lt;&lt;&lt; $message\u2019<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"74-write-script-to-print-current-date-and-time\"><strong>74. Write script to print current date and time.<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash\nyear= \u2018date +%Y\u2019\nmonth=\u2019date  +%m\u2019\nday=\u2019date +%d\u2019\nhour=\u2019date +% H\u2019\nminute=\u2019date +%M\u2019\nsecond=\u2019date +%S\u2019\necho \u2018date\u2019\necho  \u201ccurrent date is :$day-$month=$year\u201d\necho  \u201ccurrent time is :$hour:$minute:$second\u201d<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"career-growth\"><strong>Career growth\u00a0<\/strong><\/h2>\n\n\n\n<p>There are a lot of opportunities from many reputed companies in the world. According to research, Linux Shell Scripting has a market share of about 17. Since 2018, Linux has started to expand its market rapidly. According to PayScale, the average salary for shell scripting skill is $81,951. If you want career growth in DevOps, System administrator, learning shell scripting interview questions would be a great start.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"daily-use-examples-of-shell-scripting-by-system-admins\"><strong>Daily use Examples of Shell Scripting by System Admins<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Monitoring your Linux system.<\/li>\n\n\n\n<li>Data backup and creating snapshots.<\/li>\n\n\n\n<li>Dumping Oracle or MySQL database for backup.<\/li>\n\n\n\n<li>Creating email based alert systems.<\/li>\n\n\n\n<li>Find out what processes are eating up your system resources.<\/li>\n\n\n\n<li>Find out available and free memory.<\/li>\n\n\n\n<li>Find out all logged in users and what they are doing.<\/li>\n\n\n\n<li>Find out if all necessary network services are running or not. For example if the web server failed then send an alert to the system administrator via a pager or an email.<\/li>\n\n\n\n<li>Find out all failed login attempts, if login attempts are continued repeatedly from the same network IP automatically block all those IPs accessing your network\/service via firewall.<\/li>\n\n\n\n<li>User administration as per your own security policies.<\/li>\n\n\n\n<li>Find out information about local or remote servers.<\/li>\n\n\n\n<li>Server configuration.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"shell-scripting-faqs\"><strong>Shell Scripting FAQs<\/strong><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1662533593877\"><strong class=\"schema-faq-question\">When should shell programming scripting not be used?<\/strong> <p class=\"schema-faq-answer\">Shell programming scripting shouldn\u2019t be used if a task is extremely complex, such as while writing a payroll processing system or when a high degree of productivity is required.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1662533873182\"><strong class=\"schema-faq-question\"><strong>What is $1 and $2 in shell script?<\/strong><\/strong> <p class=\"schema-faq-answer\">In shell scripting, $1 refers to the first argument or filename1, $2 refers to the second argument.\u00a0<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1662533967395\"><strong class=\"schema-faq-question\"><strong>What is the importance of shell scripting?<\/strong><\/strong> <p class=\"schema-faq-answer\">Shell scripting is extremely beneficial when it comes to reducing repetitive tasks that are time consuming and need to be executed by typing one line at a time. It can be used to automate the code compiling process, creating a program environment, running a program, and much more.\u00a0<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1662534090416\"><strong class=\"schema-faq-question\"><strong><strong>What is Z in bash?<\/strong><\/strong><\/strong> <p class=\"schema-faq-answer\">The -z flag parameter in bash is helpful to check whether the length of a variable is zero and returns true if it is zero.\u00a0<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1662534734451\"><strong class=\"schema-faq-question\">Is bash a OOP?<\/strong> <p class=\"schema-faq-answer\">No, Bash is a scripting language and does not support OOP.\u00a0<\/p> <\/div> <\/div>\n\n\n\n<p>This brings us to the end of the blog on shell scripting interview questions. We hope that you were able to benefit from this blog on shell scripting interview questions and are now better-equipped to attend your upcoming interviews. <\/p>\n\n\n\n<p>If you wish to upskill in this domain and learn more concepts, check out the various <a rel=\"noreferrer noopener\" href=\"https:\/\/www.mygreatlearning.com\/academy\" target=\"_blank\">Free Online Courses offered by Great Learning Academy. <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Shell scripts are programs that contain commands to be executed by a shell, which is a command-line interpreter. Long repetitive series of commands are compiled into a single script, thereby largely reducing repetitive work. Shell scripts are used for program execution, file manipulation, and printing text. One of the common uses of shell scripting is [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":30924,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[],"content_type":[36249],"class_list":["post-30883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","content_type-interview-questions"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>70+ Shell Scripting Interview Questions and Answers<\/title>\n<meta name=\"description\" content=\"70+ Shell scripting interview questions: In this blog we have covered the various commonly asked questions to help you.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Top 70+ Shell Scripting Interview Questions &amp; Answers\" \/>\n<meta property=\"og:description\" content=\"70+ Shell scripting interview questions: In this blog we have covered the various commonly asked questions to help you.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-04T10:49:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-18T08:27:33+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1254\" \/>\n\t<meta property=\"og:image:height\" content=\"837\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Top 70+ Shell Scripting Interview Questions &amp; Answers\",\"datePublished\":\"2023-01-04T10:49:22+00:00\",\"dateModified\":\"2024-11-18T08:27:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/\"},\"wordCount\":2871,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-1171209883.jpg\",\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/\",\"name\":\"70+ Shell Scripting Interview Questions and Answers\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-1171209883.jpg\",\"datePublished\":\"2023-01-04T10:49:22+00:00\",\"dateModified\":\"2024-11-18T08:27:33+00:00\",\"description\":\"70+ Shell scripting interview questions: In this blog we have covered the various commonly asked questions to help you.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533593877\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533873182\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533967395\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662534090416\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662534734451\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-1171209883.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-1171209883.jpg\",\"width\":1254,\"height\":837,\"caption\":\"shell scripting interview questions\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Top 70+ Shell Scripting Interview Questions &amp; Answers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533593877\",\"position\":1,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533593877\",\"name\":\"When should shell programming scripting not be used?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Shell programming scripting shouldn\u2019t be used if a task is extremely complex, such as while writing a payroll processing system or when a high degree of productivity is required.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533873182\",\"position\":2,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533873182\",\"name\":\"What is $1 and $2 in shell script?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"In shell scripting, $1 refers to the first argument or filename1, $2 refers to the second argument.\u00a0\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533967395\",\"position\":3,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662533967395\",\"name\":\"What is the importance of shell scripting?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Shell scripting is extremely beneficial when it comes to reducing repetitive tasks that are time consuming and need to be executed by typing one line at a time. It can be used to automate the code compiling process, creating a program environment, running a program, and much more.\u00a0\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662534090416\",\"position\":4,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662534090416\",\"name\":\"What is Z in bash?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"The -z flag parameter in bash is helpful to check whether the length of a variable is zero and returns true if it is zero.\u00a0\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662534734451\",\"position\":5,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/shell-scripting-interview-questions\\\/#faq-question-1662534734451\",\"name\":\"Is bash a OOP?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No, Bash is a scripting language and does not support OOP.\u00a0\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"70+ Shell Scripting Interview Questions and Answers","description":"70+ Shell scripting interview questions: In this blog we have covered the various commonly asked questions to help you.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/","og_locale":"en_US","og_type":"article","og_title":"Top 70+ Shell Scripting Interview Questions &amp; Answers","og_description":"70+ Shell scripting interview questions: In this blog we have covered the various commonly asked questions to help you.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2023-01-04T10:49:22+00:00","article_modified_time":"2024-11-18T08:27:33+00:00","og_image":[{"width":1254,"height":837,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Top 70+ Shell Scripting Interview Questions &amp; Answers","datePublished":"2023-01-04T10:49:22+00:00","dateModified":"2024-11-18T08:27:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/"},"wordCount":2871,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg","articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/","url":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/","name":"70+ Shell Scripting Interview Questions and Answers","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg","datePublished":"2023-01-04T10:49:22+00:00","dateModified":"2024-11-18T08:27:33+00:00","description":"70+ Shell scripting interview questions: In this blog we have covered the various commonly asked questions to help you.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533593877"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533873182"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533967395"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662534090416"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662534734451"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg","width":1254,"height":837,"caption":"shell scripting interview questions"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"Top 70+ Shell Scripting Interview Questions &amp; Answers"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533593877","position":1,"url":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533593877","name":"When should shell programming scripting not be used?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Shell programming scripting shouldn\u2019t be used if a task is extremely complex, such as while writing a payroll processing system or when a high degree of productivity is required.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533873182","position":2,"url":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533873182","name":"What is $1 and $2 in shell script?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"In shell scripting, $1 refers to the first argument or filename1, $2 refers to the second argument.\u00a0","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533967395","position":3,"url":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662533967395","name":"What is the importance of shell scripting?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Shell scripting is extremely beneficial when it comes to reducing repetitive tasks that are time consuming and need to be executed by typing one line at a time. It can be used to automate the code compiling process, creating a program environment, running a program, and much more.\u00a0","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662534090416","position":4,"url":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662534090416","name":"What is Z in bash?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"The -z flag parameter in bash is helpful to check whether the length of a variable is zero and returns true if it is zero.\u00a0","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662534734451","position":5,"url":"https:\/\/www.mygreatlearning.com\/blog\/shell-scripting-interview-questions\/#faq-question-1662534734451","name":"Is bash a OOP?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"No, Bash is a scripting language and does not support OOP.\u00a0","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg",1254,837,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883-768x513.jpg",768,513,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883-1024x683.jpg",1024,683,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg",1254,837,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883.jpg",1254,837,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883-640x837.jpg",640,837,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883-96x96.jpg",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1171209883-150x100.jpg",150,100,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":1,"uagb_excerpt":"Shell scripts are programs that contain commands to be executed by a shell, which is a command-line interpreter. Long repetitive series of commands are compiled into a single script, thereby largely reducing repetitive work. Shell scripts are used for program execution, file manipulation, and printing text. One of the common uses of shell scripting is&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/30883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=30883"}],"version-history":[{"count":84,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/30883\/revisions"}],"predecessor-version":[{"id":108176,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/30883\/revisions\/108176"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/30924"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=30883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=30883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=30883"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=30883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}