Here is a small shell script that counts the lines, words and characters in a file. Most shell scripts utilize other programs. In this case, it is wc, the standard Unix utility to count words, lines and characters in a file. Without further delay, let's get into the source code. We'll explain it later.
Please note that this article assumes you already know how to write and execute a shell script.
Code
#!/bin/bash
echo -n "Enter the filename: "
read path
read lines words chars filename
Keywords (click to browse): word-count wc counting file-statistics shell sh bash linux gnu unix script programming command-line