added a bunch of helper scripts
This commit is contained in:
parent
f72408cd88
commit
a24aeeffe7
6 changed files with 347 additions and 0 deletions
29
csvfix.sh
Executable file
29
csvfix.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check if filename parameter is provided
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <csv_filename>"
|
||||
echo "Example: $0 data.csv"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CSV_FILE="$1"
|
||||
|
||||
# Check if file exists
|
||||
if [ ! -f "$CSV_FILE" ]; then
|
||||
echo "Error: File '$CSV_FILE' not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Processing file: $CSV_FILE"
|
||||
echo "========================================"
|
||||
|
||||
# Count prefixes from first column
|
||||
echo -e "\n=== Total number of unique prefixes ==="
|
||||
cut -d',' -f1 "$CSV_FILE" | sort | uniq | wc -l
|
||||
|
||||
# Readable output format
|
||||
echo "=== Formatted output ==="
|
||||
echo "Prefix -> Count"
|
||||
echo "---------------"
|
||||
cut -d',' -f1 "$CSV_FILE" | sort | uniq -c | sort -nr | awk '{printf "%-20s -> %d\n", $2, $1}'
|
Loading…
Add table
Add a link
Reference in a new issue