#!/bin/bash # Prompt the user to enter the filename echo "Enter the filename:" read filename # Check if the file exists if [ ! -f "$filename" ]; then echo "File not found!" exit 1 fi # Count the number of characters, words, and lines in the file using grep num_chars=$(grep -o . "$filename" | wc -l) num_words=$(grep -o '\w\+' "$filename" | wc -l) num_lines=$(grep -c . "$filename") # Print the results echo "Number of characters: $num_chars" echo "Number of words: $num_words" echo "Number of lines: $num_lines"