Linux Questions & Answers on Shell Programming for Freshers

1. What will be output of following command:
$ echo "The process id is" $$$$
 
a) The process id is $$
b) The process id is $<pid>$<pid>
c) The process id is <pid><pid>
d) The process id is $$$$

Answer: c
 
2. What would be the current working directory at the end of the following command sequence?
 $ pwd
 /home/user1/proj
 $ cd  src
 $ cd  generic
 $ cd  .
 $ pwd
a) /home/user1/proj
b) /home/user1/proj/src
c) /home/user1
d) /home/user1/proj/src/generic
Answer: d
3. How do you print the lines between 5 and 10, both inclusive

a) cat filename | head | tail -6
b) cat filename | head | tail -5
c) cat filename | tail +5 | head
d) cat filename | tail -5 | head -10
Answer: a
4. Create a new file “new.txt” that is a concatenation of “file1.txt” and “file2.txt”

a) cp file.txt file2.txt new.txt
b) cat file1.txt file2.txt > new.txt
c) mv file[12].txt new.txt
d) ls file1.txt file2.txt | new.txt
Answer: b
5. which of these is NOT a valid variable in bash

a) __ (double underscore)
b) _1var (underscore 1 var )
c) _var_ (underscore var underscore)
d) some-var (some hyphen var)
Answer: d
6. What is the output of the following code:
os=Unix
echo 1.$os 2."$os" 3.'$os' 4.$os
a) 1.Unix 2.Unix 3.Unix 4.Unix
b) 1.Unix 2.Unix 3.$os 4.Unix
c) 1.Unix 2.Unix 3.Unix 4.$os
d) 1.Unix 2.$os 3.$os 4.$os
Answer: b
7. What is the return value ($?) of this code:
os = Unix
[$osName = UnixName] && exit 2
[${os}Name = UnixName] && exit 3
a) 0
b) 1
c) 2
d) 3
Answer: d
8. What is the output of the following program?
x = 3; y = 5; z = 10;
if [( $x -eq 3 ) -a ( $y -eq 5 -o  $z -eq 10 )]
then
    echo $x
else
    echo $y
fi
a) 1
b) 3
c) 5
d) Error
Answer: b
9. What is the output of the following program?
[ -n $HOME ]
echo $?
[ -z $HOME ]
echo $?
a) 0
   1
b) 1
   0
c) 0
   0
d) 1
   1

Answer: a
10. What is the output of the following program?
b = 
[ -n $b ]
    echo $?
[ -z $b ]
    echo $?
a) 1
   1
b) 2
   2
c) 0
   0
d) 0
   1

Answer: c
 
 
11. The expression expr -9 % 2 evaluates to:

a) 0
b) 1
c) -1
d) 2
Answer: c
12. The statement z = ‘expr 5 / 2’ would store which of the following values in z?

a) 0
b) 1
c) 2
d) 2.5
Answer: c

Related

C Programming Questions and Answers on Static Variables for Freshers

1. What is the output of this C code? #include void main() { m(); m(); } void m() { static int x = 5; x++; printf...

HTML Multiple Choice Questions & Answers on Embracing the Reality of Web Markup for Freshers

1. Which of the following element represents a thematic break rather than a horizontal rule, though that is the likely representation? a) <dd> b) <dt> c) <hr> d) ...

Java Multiple Choice Questions & Answers on String Comparison for Freshers

1. Which of these method of class String is used to compare two String objects for their equality? a) equals()b) Equals()c) isequal()d) Isequal() Answer: a 2. Which of these methods is used to co...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item