Practical Interview Questions and Answers on Linux Shell Scripting

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

9 Responses

  1. Jyotimoi says:

    Thanks ! It was helpful
    Please post more related to shell scripting.:-)

  2. Joseph in Atlanta says:

    Question #5 (display PI to 100 places) The “pi” command is an obscure command on Unix/Linux, that 75% of root sysadmin professionals don’t have occasion to use with 10yrs of real-job work.

    Shell scripts for business are more about server control, admin, performance tuning, storage management, databases, networking, security, monitoring, clusters, install/upgrade, reporting, and user-id setup… so they seldom need value of “pi”, let alone to 100 digits.

    The “pi” command is not even present for many Unix versions such as HP-UX, IBM’s AIX, Solaris, etc… which means you generally would not use that command in a shell script that can be used with MANY kinds of servers.

    Alternately, the “bc” command line calculator IS present on almost every form of Unix, and can also be used to calculate the value of “pi” like this:

    $  echo "scale=100 a(1)*4" | bc -l              ## Note: function a(x) is "arc-tangent(x)

    SO: While this is a valid question/answer for Linux, it may not be an accurate assessment of someone’s real-world experience on the job.

    • Aaron Kili K says:


      Your analysis is on point here, however, this command : $ echo “scale=100 a(1)*4” | bc -l actually has a syntax error. It is missing a minor but important ; sign after the scale value, the correct syntax as per Bash shell is:

      $ echo “scale=100; a(1)*4” | bc -l

      You could be using another shell, you can let us know, above all thanks for your vital concerns and productive feedback.

    • Kevin says:

      Hello There,

      Thank you, Your blog is indeed quite interesting around Practical Interview Questions and Answers on Linux Shell Scripting! I agree with you on lot of points!

      By the way do you have any YouTube videos, would love to watch it. I would like to connect you on LinkedIn, great to have experts like you in my connection (In case, if you don’t have any issues).

      Thank you,

  3. Joseph in Atlanta says:

    Script for question#2 (adding two parameter numbers) uses expr $1 + $2` which is an OLD shell scripting syntax for addition, that has been around since 1973, and is less efficient because it uses a separate binary process just for the math.

    The preferred form in Korn/ksh shell or bash is: $(( $1 + $2 )) which runs faster because it uses the built-in math support from the shell, rather than separate process.

    Shell scripts using `expr` Will run OK, but is not considered ‘good form’ and most shell script writers will not give that answer… so I would not want somebody giving an interview to think that $(( $1 + $2 )) is in-correct.

    • Aaron Kili K says:


      You are absolutely correct, Although they both methods work just fine, however, using $(( $1 + $2 )) is more efficient than `expr $1 + $2`. I often use the former for mathematical expressions in shell scripts.

  4. Thanks! That was useful escpecially reversing a given number.

Leave a Reply to Joseph in Atlanta Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.