1.

test command can be used to check which of the following?(a) Compare two numbers(b) Compare two strings(c) Check attributes of a file(d) All of the mentionedI had been asked this question in an interview for job.The query is from Using test and [ ] to Evaluate Expressions in division Essential Shell Programming of Unix

Answer» CORRECT answer is (d) All of the mentioned

To explain I would say: When we use if to evaluate expressions, we need the test statement because the true or false values RETURNED by expressions can’t be directly handled by if. The test uses certain operators to evaluate the condition on its right and returns EITHER true or false exit status. test works in three ways:

•compares two numbers

•compare two strings or a SINGLE ONE for a null value

•check a file’s attributes


Discussion

No Comment Found

Related InterviewSolutions