MTI TEK
  • Home
  • About
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • All Resources
Linux-Ubuntu | wc - print word counts
  1. Notes
  2. Examples
  3. Command Help (man wc)

  1. Notes
    wc [OPTION]... [FILE]...
    
  2. Examples
    • Count files and folders:
      $ ls | wc -w
      14
      
    • Count lines in a file:
      $ wc -l test.txt
      26 test.txt
      
    • Count words in a file:
      $ wc -w test.txt
      42 test.txt
      
    • Count characters in a file:
      $ wc -m test.txt
      156 test.txt
      
    • Count bytes in a file:
      $ wc -c test.txt
      156 test.txt
      
    • Show all counts (lines, words, characters):
      $ wc test.txt
      26 42 156 test.txt
      
    • Count multiple files:
      $ wc -l file1.txt file2.txt
      15 file1.txt
      20 file2.txt
      35 total
      
    • Count from standard input:
      $ echo "hello world" | wc -w
      2
      
  3. Command Help (man wc)
    The following options can be used:
    -l, --lines
        print the newline counts
    
    -w, --words
        print the word counts
    
    -m, --chars
        print the character counts
    
    -c, --bytes
        print the byte counts
    
    -L, --max-line-length
        print the maximum display width
    
    --files0-from=F
        read input from the files specified by NUL-terminated names in file F
    
    --help
        display this help and exit
    
    --version
        output version information and exit
    
© 2025 mtitek