Computer Science, asked by sh8igrachanp, 1 year ago

The basic UNIX Debian Command
What does this mean in Unix grep -c usb * | grep -v :0 2> /dev/null?

Answers

Answered by kvnmurty
0
grep   -c  usb  *  |  grep -v :0  2> /dev/null

    This prints the total count of the number of files (excluding hidden files) in the current directory, that contain the  string  "usb".

================
grep is used to  check and print the lines in a text file, that contain a given string or string pattern specified by UNIX pattern matching mechanism.
 
  There are two grep processes with the std output of the first one directed to the std input of the other.   "  |  "  pipe symbol indicates pipe (ipc).

The command line options/args.  

-c   =>  prints only file name and the number of lines matching the pattern.
"usb"   =>  is the string searched for
 *      =>   all files in the current directory that start with alphanumeric char or,  all files not hidden.

-v   =>  invert matching.  So print number of lines not matching with pattern.
":0"    =>  pattern to match
2> /dev/null       =>    any std. error messages are redirected to null device and not on screen.



Similar questions