script to show all files with disk usage sizes
Normally to get the disk usage of a folder you use get properties on the rightclick or similar. However there are hidden files starting with . in their name that you can get info on, only in the terminal, using the du -sh command. If you have hundreds of them (which you do!) this becomes tedious. The following script gives you a directory listing with the files all indicated in file sizes and highlights on files of megabytes or gigabytes in size.
#!/bin/bash
# Set Internal Field Separator to handle spaces in filenames
IFS=$'\n'
# Loop through all files and directories
for i in $(/bin/ls -A); do
size=$(du -sh "$i" | awk '{print $1}')
# Apply colors: bold for MB, bright bold for GB
case "$size" in
*M) color="\e[1m" ;; # Bold for Megabytes
*G) color="\e[1;97m" ;; # Bright bold (white) for Gigabytes
*) color="" ;; # Default for others
esac
# Print formatted output with coloring
printf "%-50s %b%10s\e[0m\n" "$i" "$color" "$size"
done | less -R