What command is used to count the number of files in the current directory by using pipes? A. ls | ws – c B. ls | wc – w C. ls | wc – l D. ls | wc E. None of the above

ls | ws - c
ls | wc - w
ls | wc - l
ls | wc E. None of the above

The correct answer is: ls | wc -l.

The ls command lists the files in the current directory. The | character is a pipe, which sends the output of the ls command to the input of the wc command. The wc command counts the number of lines, words, and characters in its input. The -l option tells wc to count lines only.

The other options are incorrect. ws -c is not a valid command. ls | wc -w would count the number of words in the output of ls, which would not be the number of files in the current directory. ls | wc -l would count the number of lines in the output of ls, which would also not be the number of files in the current directory.

Exit mobile version