2025-04-12 01:10:09 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Check if input and output files are provided
|
|
|
|
|
if [ $# -ne 2 ]; then
|
2025-11-01 15:36:22 +01:00
|
|
|
echo "Usage: $0 input_file.txt output_file.txt"
|
|
|
|
|
exit 1
|
2025-04-12 01:10:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check if the input file exists
|
|
|
|
|
if [ ! -f "$1" ]; then
|
2025-11-01 15:36:22 +01:00
|
|
|
echo "Error: File '$1' not found"
|
|
|
|
|
exit 1
|
2025-04-12 01:10:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Store output file name
|
|
|
|
|
output_file="$2"
|
|
|
|
|
|
|
|
|
|
# Clear output file at the beginning
|
2025-11-01 15:36:22 +01:00
|
|
|
: > "$output_file"
|
2025-04-12 01:10:09 +02:00
|
|
|
|
2026-05-15 00:32:35 +02:00
|
|
|
# Process file: extract 5-8 char alphabetic words, uppercase, deduplicate
|
|
|
|
|
# grep -oE extracts words directly (replaces two tr passes), sort -u deduplicates
|
|
|
|
|
grep -oE '[a-zA-Z]{5,8}' < "$1" | tr '[:lower:]' '[:upper:]' | sort -u > "$output_file"
|
2025-04-12 01:10:09 +02:00
|
|
|
|
|
|
|
|
echo "Processing complete. Results saved to '$output_file'"
|