1.

To replace the string ‘director’ in the first five lines of file emp.lst with ‘manager’ we can use _____(a) sed‘s/director/manager/’ emp.lst(b) sed ‘1-5s/director/manager/’ emp.lst(c) sed ‘1,5s/director/manager/’ emp.lst(d) sed ‘15sThis question was addressed to me in an internship interview.I need to ask this question from sed command in portion Filters using Regular Expressions of Unix

Answer»

Right answer is (c) sed ‘1,5s/director/manager/’ emp.lst

For EXPLANATION I would say: Performing SUBSTITUTION using sed is not only limited to a single CHARACTER; it can be any STRING. Above command will replace the string ‘director’ with ‘manager’ in the FIRST five lines of file emp.lst.



Discussion

No Comment Found

Related InterviewSolutions