Shell Scripting

30 Questions | Total Attempts: 933

SettingsSettingsSettings
Shell Scripting - Quiz

Test your Shell scripting skills. Good Luck !


Questions and Answers
  • 1. 
    Which of the following is not a proper shell name?
    • A. 

      Csh : C shell

    • B. 

      Ksh : Korn Shell

    • C. 

      Bash : bourne again shell

    • D. 

      Ssh : sea shell

  • 2. 
    In Shell scripting, What does $? Return? 
    • A. 

      $? will return exit status of command .0 if command gets successfully executed ,non-zero if command failed.

    • B. 

      $? will return exit status of command .Non-0 if command gets successfully executed ,zero if command failed.

    • C. 

      System error

    • D. 

      Invalid command

  • 3. 
    In Shell scripting, What does $# stand for? 
    • A. 

      Will return no of error

    • B. 

      Will return the number of parameters that are passed as the command-line arguments

    • C. 

      Error

    • D. 

      None of the above

  • 4. 
    In Shell scripting, what is  $*?
    • A. 

      Its mainly used for showing up all params. This show few parameter values passed in shell script

    • B. 

      Its mainly used for showing up all params. This show all values returned

    • C. 

      Its mainly used for showing up all params. This show all parameter values passed in shell script

    • D. 

      None of the above

  • 5. 
    How do you find out what’s your shell? 
    • A. 

      Whomami

    • B. 

      Pwd

    • C. 

      Echo $SHELL

    • D. 

      $sh

  • 6. 
    Why should the Bourne shell be used for writing shell scripts?
    • A. 

      Easily available

    • B. 

      Standard and portable

    • C. 

      Easy to use

    • D. 

      Available on all the system

  • 7. 
    How do shell scripts receive input?
    • A. 

      By reading keyboard data entered by a user

    • B. 

      By using the output of another program as input

    • C. 

      By using a file’s contents as input

    • D. 

      All of the above

  • 8. 
    Which one of the following files contains the name of your login shell?
    • A. 

      /etc/passwd

    • B. 

      /etc/login

    • C. 

      /etc/hosts

    • D. 

      /etc/profile

  • 9. 
    When a shell script begins, it has an initial value for the PATH variable. Where does this value come from?
    • A. 

      It’s passed down from the script’s parent shell

    • B. 

      It’s passed up from the script’s child shell

    • C. 

      It’s read by the script from the /etc/profile file

    • D. 

      It’s read by the script from the .profile file.

  • 10. 
    Which shell is the parent process of the Korn shell seen in the listing above?
    • A. 

      The Korn Shell

    • B. 

      The Bourne shell

    • C. 

      The C shell

    • D. 

      The bash shell

  • 11. 
    Which quoting mechanism is used to protect $, > and * from shell?  
    • A. 

      Single

    • B. 

      Double

    • C. 

      Back quote

    • D. 

      None of the above

  • 12. 
    Study the following steps: name=cat namelast=meow echo $name `echo last` How can the above echo command be modified to display the string meow?
    • A. 

      Eval echo \$name `echo last`

    • B. 

      Eval ‘$name’ `echo last`

    • C. 

      Echo “$name” $namelast

    • D. 

      Both eval echo \$name `echo last` & eval ‘$name’ `echo last`

  • 13. 
    How to check if a file is present in a particular directory in Unix?
    • A. 

      Ls –l myFile.txt; echo $?

    • B. 

      Ls –l myFile.txt; echo $#

    • C. 

      Ls –l myFile.txt; echo $$

    • D. 

      Ls –l myFile.txt; echo $*

  • 14. 
    How to remove the last line/ trailer from a file in UNIX?
    • A. 

      Sed –i '^ d' file.txt

    • B. 

      Sed –i '$ d' file.txt

    • C. 

      Sed –i '$ p' file.txt

    • D. 

      Sed –i '$ c' file.txt

  • 15. 
    Which command is used to sort the lines of data in a file in reverse order?
    • A. 

      Sort

    • B. 

      Sh

    • C. 

      St

    • D. 

      Sort -r

  • 16. 
    Which command is used to display the top of the file?
    • A. 

      Cat

    • B. 

      Head

    • C. 

      More

    • D. 

      Grep

  • 17. 
    Which symbol will be used with grep command to match the pattern pat at the beginning of a line?
    • A. 

      ^pat

    • B. 

      $pat

    • C. 

      Pat$

    • D. 

      Pat^

  • 18. 
    Which command is used to change protection mode of files starting with the string emp and ending with 1,2, or 3?
    • A. 

      Chmod u+x emp[l-3]

    • B. 

      Chmod 777 emp*

    • C. 

      Chmod u+r ??? emp

    • D. 

      Chmod 222 emp?

  • 19. 
    How can you display a list of all files, including the hidden files?
    • A. 

      All

    • B. 

      Ls -a

    • C. 

      Find -a

    • D. 

      Find all

  • 20. 
    How to create a new file without opening it?
    • A. 

      Less filename

    • B. 

      Touch filename

    • C. 

      More filename

    • D. 

      Cat filename

  • 21. 
    What do you use to forward errors to a file?
    • A. 

      2> filename

    • B. 

      2> /dev/null

    • C. 

      &> filename

    • D. 

      Filename

  • 22. 
    With what can you stop a process? 
    • A. 

      Delete

    • B. 

      Kill

    • C. 

      Stop

    • D. 

      Shutdown

  • 23. 
    With what command you can see what folder you are in?
    • A. 

      Place

    • B. 

      Map

    • C. 

      Whereami

    • D. 

      Pwd

  • 24. 
    Which command is most useful when you want not only to send some data down a pipe, but also to save a copy?
    • A. 

      Pipe

    • B. 

      Awk

    • C. 

      Split

    • D. 

      Tee

  • 25. 
    Shell programs are?
    • A. 

      Compiled

    • B. 

      Interpreted

    • C. 

      Command processed

    • D. 

      None of the above

Back to Top Back to top