mirror of
https://github.com/Erreur32/cheat.git
synced 2024-12-22 21:52:12 +01:00
18 lines
554 B
Text
18 lines
554 B
Text
# Count the number of words (file or STDIN)
|
|
wc -w /path/to/foo.txt
|
|
cat /path/to/foo.txt | wc -w
|
|
|
|
# Count the number of lines (file or STDIN)
|
|
wc -l /path/to/foo.txt
|
|
cat /path/to/foo.txt | wc -l
|
|
|
|
# Count the number of bytes (file or STDIN)
|
|
wc -c /path/to/foo.txt
|
|
cat /path/to/foo.txt | wc -c
|
|
|
|
# Count files and directories at a given location
|
|
ls -l | wc -l
|
|
|
|
# If you ever use `wc` in a shell script and need to compare the output with an int you can
|
|
# clean the output (wc returns extra characters around the integer) by using xargs:
|
|
ls -l | wc -l | xargs
|