Shell

30 bash script Interview questions and answers

30 bash script Interview questions and answers
  1. What is difference between $$ and $!?
  2. What is a shell script answer?
  3. What is $1 and $2 in shell script?
  4. What is $? In bash script?
  5. Is it correct to say thinking of you?
  6. Can I talk to or with?
  7. How do I run a shell script?
  8. How do I debug a shell script?
  9. Why shell scripting is used?
  10. What does echo $1 mean?
  11. What is $0 shell?
  12. What is $@ in Shell?

What is difference between $$ and $!?

$$ gives the process id of the currently executing process whereas $! Shows the process id of the process that recently went into the background.

What is a shell script answer?

A shell script is a command-containing text-file that contains commands in order of their execution. Typical operations performed by shell scripts include printing text, file manipulation, and program execution.

What is $1 and $2 in shell script?

$1 is the first command-line argument passed to the shell script. ... $0 is the name of the script itself (script.sh) $1 is the first argument (filename1) $2 is the second argument (dir1)

What is $? In bash script?

$? -The exit status of the last command executed. $0 -The filename of the current script. $# -The number of arguments supplied to a script. $$ -The process number of the current shell.

Is it correct to say thinking of you?

Which is correct, thinking of you or thinking about you? Both sentences are correct, but their meaning depends on what you mean when using either. “Thinking of you” usually appeals instantly to the emotions. It suggests an individual 'dreaming ' of the person he or she loves.

Can I talk to or with?

In both the cases, the meaning is "have a conversation with somebody." The difference is that speak to (or talk to) is less polite, since it put the emphasis on one doing the conversation, while speak with (or talk with) is more polite, since it doesn't put the emphasis on just one doing the conversation.

How do I run a shell script?

Steps to write and execute a script

  1. Open the terminal. Go to the directory where you want to create your script.
  2. Create a file with . sh extension.
  3. Write the script in the file using an editor.
  4. Make the script executable with command chmod +x <fileName>.
  5. Run the script using ./<fileName>.

How do I debug a shell script?

Bash shell offers debugging options which can be turn on or off using the set command:

  1. set -x : Display commands and their arguments as they are executed.
  2. set -v : Display shell input lines as they are read.

Why shell scripting is used?

A shell script is a program that is used to perform specific tasks. ... Shell scripts are mostly used to avoid repetitive work. You can write a script to automate a set of instructions to be executed one after the other, instead of typing in the commands one after the other n number of times.

What does echo $1 mean?

$1 is the argument passed for shell script. then. $1 will be hello. $2 will be 123.

What is $0 shell?

$0 Expands to the name of the shell or shell script. This is set at shell initialization. If Bash is invoked with a file of commands (see Section 3.8 [Shell Scripts], page 39), $0 is set to the name of that file.

What is $@ in Shell?

$@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.

How To Install Odoo 13 on CentOS 7
How To Install Odoo 13 on CentOS 7 Step 1 Add EPEL Repository. ... Step 2 Install PostgreSQL Database Server. ... Step 3 Install wkhtmltopdf. ... Step...
Ubuntu Data Collection Report is Out! Read the Interesting Facts
What information does Ubuntu collect? Does Ubuntu steal your data? Does Ubuntu spy on users? Is Ubuntu good for privacy? Does Ubuntu still send data t...
How to Install Sendmail on Fedora 32/31/30
How do I install Sendmail? Where is Sendmail cf in Linux? How do I enable port 587 on Sendmail? Where is Sendmail located? Which is better postfix or ...