Skip to content

UGC NET CS 2019System Software and Operating System › Linux Operating SystemsVerified

UGC NET CS 2019 PYQ: Which of the following UNIX/Linux pipes will count the number of lines in all the files having .c and .h as…

Which of the following UNIX/Linux pipes will count the number of lines in all the files having .c and .h as their extension in the current working directory?

  1. A
    cat $* \cdot$ ch $\: \mid$ wc $-1$
  2. B
    cat $* \cdot [$ c-h $] \: \mid$ wc $-1$
  3. C
    cat $* \cdot [$ ch $] \: \mid$ ls $-1$
  4. D
    cat $* \cdot [$ ch $] \: \mid$ wc $-1$
    Correct answer

Answer

(D) cat $* \cdot [$ ch $] \: \mid$ wc $-1$

Approach

Use shell globbing and wc -l to count lines.

Reviewed by UGC IQ Editorial Team.