DEV: Challenge Accepted ’23 – Task 1

What is the purpose of the script below?

#!/bin/bash

read -p "Enter the name of the text file to analyze: " FILENAME

cat "$FILENAME" | tr '[:upper:]' '[:lower:]' | sed 's/[[:punct:]]//g' | awk '{for(i=1;i<=NF;i++) {print $i}}' | sort | uniq -c | sort -nr | head -n 10

cat "$FILENAME" | tr '[:upper:]' '[:lower:]' | sed 's/[[:punct:]]//g' | awk '{for(i=1;i<=NF;i++) {print $i}}' | sort | uniq -c | sort -nr | head -n 10 > "${FILENAME}_report.txt"

echo "Report generated successfully"