Linux Questions & Answers on sed Editor for Freshers

1. What is sed?

a) a non-interactive stream editor
b) an IDE
c) a hex editor
d) none of the mentioned
Answer: a
2. Sed maintains the hold space (a buffer) to

a) copy the each line of input
b) save the data for later retrieval
c) copy the each line of input & save the data for later retrieval
d) none of the mentioned
Answer: b

Explanation: To copy the each line of input, sed maintains the pattern space.
3. Which is the correct syntax for sed on command line?

a) sed [options] ‘[command]’ [filename].
b) sed ‘[command]’ [options] [filename].
c) sed [filename] [options] ‘[command]’
d) sed ‘[command]’ [filename] [options].
Answer: a
4. If any sed command does not specify any address then the command is applied to

a) each input line
b) none of the input line
c) last input line
d) none of the mentioned
Answer: a
5. If no file is specified in sed command then

a) sed command will not work
b) sed reads from standard input
c) sed reads the data already present in buffer
d) it is necessary to provide the filename
Answer: b
6. Which sed command deletes the specified address range

a) [address range]/s
b) [address range]/p
c) [address range]/d
d) [address range]/y
Answer: c

Explanation: To use the command correct syntax specified for sed editor should be followed.
7. Which command is used to replace word ‘cat’ (already present in the file) with ‘mouse’ at all places in a file ‘old.txt’ and save the result in a new file ‘new.txt’?

a) sed ‘s/cat/mouce/g’ old.txt > new.txt
b) sed ‘s/cat/mouse’ old.txt new.txt
c) sed ‘/s/cat/mouse/g’ old.txt new.txt
d) sed ‘/s/cat/mouse’ old.txt > new.txt
Answer: a
8. Which command will delete all the blank lines in file old.txt?

a) sed ‘/d’ old.txt
b) sed ‘/^/d’ old.txt
c) sed ‘/^$/d’ old.txt
d) sed ‘/^*/d’ old.txt
Answer: c
9. The command “sed -n ‘/sanfoundry/p’ old.txt” will

a) print the lines containing the word ‘sanfoundry’ in file old.txt
b) delete the lines containing the word ‘sanfoundry’ in file old.txt
c) will generate an error message
d) none of the mentioned
Answer: a
10. Which option is used by sed to specify that the following string is an instruction or set of instructions?

a) -n
b) -e
c) -f
d) -i
Answer: a

Related

CSS Multiple Choice Questions & Answers on Using Advanced Selectors for Freshers

1.Which of the following selector selects all elements of E that have the attribute attr that end with the given value? a) E[attr^=value] b) E[attr$=value] c) E[attr*=value] d) none of the ...

C Programming Questions and Answers on Conditional Inclusion for Freshers

1. What is the output of this C code? #include #define SYSTEM 20 int main() { int a = 20; #if SYSTEM == a printf("HELLO "); #endif ...

Java Multiple Choice Questions & Answers on Interfaces for Freshers

1. Which of these keywords is used to define interfaces in Java? a) interfaceb) Interfacec) intfd) Intf Answer: a 2. Which of these can be used to fully abstract a class from its implementation? ...

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