Linux Questions & Answers on Shell Redirection for Freshers

1. The redirection 2> abc implies

a) Write file 2 to file abc
b) Write standard output to abc
c) Write standard error to abc
d) None of the mentioned
Answer: c
2. cmd 2>&1 > abc will

a) Write file2 to file1
b) Write standard output and standard error to abc
c) Write standard error to abc
d) Write standard output to abc & standard error to monitor
Answer: d
3. cmd > abc 2>&1 will

a) Write file2 to file1
b) Write standard output and standard error to abc
c) Write standard error to abc
d) Write standard output to abc & standard error to monitor
Answer: b
4. Which of these is the correct method for appending “foo” in /tmp/bar file?

a) echo foo > /tmp/bar
b) echo foo >> /tmp/bar
c) echo foo | /tmp/var
d) /tmp/bar < echo foo
Answer: b
5. Syntax to suppress the display of command error to monitor?

a) command > &2
b) command 2> &1
c) command 2> &2
d) command 2> /dev/null
Answer: d
6. The following commands gives the output like this
    #cat file1 file2
    #cat: file1: No such file or directory
    hello
    If we execute the command “cat file1 file2  1>2  2>&1” the output would be
a) cat: file1: No such file or directory hello
b) No output is displayed
c) Cat: 1>2: No such file or directory
d) hello
Answer: b
7. cat < file1 >> file2 | file3

a) file1 content will be appended to file2 and finally stored in file3
b) file1 content will be appended to file2 and file3 will be ignored
c) file2 and file3 will have same content
d) syntax error
Answer: d
8. Executing cat /etc/password > /dev/sda as superuser will

a) Write data into a regular file called /dev/sda
b) Write data to the physical device sda
c) Create a temporary file /dev/sda and write data to it
d) None of the mentioned
Answer: b
9. From where would the read statement read if the following statements were executed?
   exec < file1
   exec < file2
   exec < file3
   read line
a) It would read all the files
b) It would not read any files
c) It would read all the files in reverse order
d) It would read only file3
Answer: b

Related

Linux Questions & Answers on File Types for Freshers

1. The soft link will increase the link counter of the file.(T/F) a) Trueb) False Answer: b 2. When you use the ln command, which of the following occurs? a) a file is created that points to an ...

C# Questions & Answers on Fundamentals of Exception Handling for Freshers

1. Which among the following is NOT an exception? a) Stack Overflowb) Arithmetic Overflow or underflowc) Incorrect Arithmetic Expressiond) All of the mentioned Answer: c 2. Which among the follow...

Linux Questions & Answers on File Management for Freshers

1. By default if any regular file is created, the number of link is displayed as 1 ? a) Trueb) False Answer: a 2. How many links are created when we creat a directory file? a) 1b) 2c) 3d) 4 Ans...

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