1.

We can redirect the error message to file named newfile using __________ command.(a) catfooerrorfile(b) catfoo >errorfile(c) cat errorfile>foo(d) cat foo 2>errorfileThe question was posed to me by my school principal while I was bunking the class.This interesting question is from Redirection and Pipes in division The Shell of Unix

Answer»

Right answer is (d) cat foo 2>errorfile

The best explanation: Redirecting standard error REQUIRES the 2> symbol. Suppose if foo doesn’t EXIST then an error message ‘cannot open foo’ will be generated but we can send this message to another FILE. But here > and >> cannot be used. We have to USE 2> symbol as the file descriptor number 2 represents the standard error stream.



Discussion

No Comment Found

Related InterviewSolutions