Display the number of bytes, words and lines in a file
I intend to create a shell manuscript
df. As, I intend to key in
df name_of_file and afterwards I can get the materials of the documents.
If the documents name remains in the directory site, I desire it to show its materials. Otherwise, I intend to show the dimension in words, lines, and also bytes. Just how do I deal with this? Until now, I have this:
#!/bin/bash FILENAME=$FILENAME FILEBYTES=$(stat -c%s "$FILENAME") FILEWORDS=$(stat -w%s "$FILENAME") FILELINES=$(stat -l%s "$FILENAME") echo "Size of $FILENAME in bytes = $FILEBYTES bytes, $FILEWORDS words, $FILELINES lines."