count lines, words and files
Count the lines of a file or of a command's output, the words, and the files in a folder.
Steps
-
wc -l file.txtthe lines of a file
-
wc -l *.csvthe lines of each file, and the total
-
wc -w file.txtthe words
-
grep -c . file.txtthe lines that are not empty
-
ls | wc -lthe files and folders here
-
find . -type f | wc -levery file under this folder
Commands used
wcgrepfind
Each has a page in lore: lore wc opens it.
Related recipes
- compare two foldersFind which files differ between two folders, or are only in one of them.
- delete lines containing a textRemove every line of a file that contains a word, or keep only those lines.
- find files containing a textSearch every file under a folder for a word or a phrase, and show where it is.
- replace text in a fileChange every place a word or a phrase appears in a file, keeping a copy if you like.