Skip to content

Instantly share code, notes, and snippets.

@dmhendricks
Last active January 6, 2019 20:28
Show Gist options
  • Save dmhendricks/83815167dcfb8128088aac0d4f54643c to your computer and use it in GitHub Desktop.
Save dmhendricks/83815167dcfb8128088aac0d4f54643c to your computer and use it in GitHub Desktop.
BASH Scripts

BASH Scripts

List Top 10 Largest Files in Current Directory

./large-files.sh 10

#!/bin/bash
usage() {
cat <<EOM
Usage: $(basename $0) [int]
Parameter:
- int: Number of top results to return
Examples:
./$(basename $0) 10
EOM
exit 0
}
[ -z $1 ] && { usage; }
#find . -type f -print0 | xargs -0 ls -la | awk '{print int($5/1000) " KB\t" $9}' | sort -n -r -k1 | head -$1
find . -type f -ls | sort -k 7 -r -n | head -$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment