Which command is used to display all the lines with the string ‘sales’ from the file empl.lst? A. cut sales empl.lst B. /sales > empl.lst C. grep sales empl.lst D. cat | /sales > empl.lst E. None of the above

”cut
”/sales
”grep
”cat

The correct answer is C. grep sales empl.lst.

The grep command is used to search for a pattern in a file. In this case, we are searching for the string “sales” in the file empl.lst. The grep command will return all the lines in the file that contain the string “sales”.

The other options are not correct.

  • Option A, cut sales empl.lst, will cut the lines in the file empl.lst that contain the string “sales”. This is not what we want to do. We want to display all the lines in the file that contain the string “sales”.
  • Option B, /sales > empl.lst, will redirect the output of the command /sales to the file empl.lst. This is not what we want to do. We want to use the grep command to search for the string “sales” in the file empl.lst.
  • Option D, cat | /sales > empl.lst, will pipe the output of the command cat to the command /sales. This is not what we want to do. We want to use the grep command to search for the string “sales” in the file empl.lst.
Exit mobile version