From 40de9a6c860631fcbc933228850f74d4aa367258 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 14 Jun 2017 13:13:47 +1200 Subject: Switch to using awk for line counting in dub(1df) Seems a bit nicer, passing the variable in as data rather than code --- bin/dub.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/dub.sh b/bin/dub.sh index c30749af..2dfd77f0 100644 --- a/bin/dub.sh +++ b/bin/dub.sh @@ -4,7 +4,7 @@ self=dub # First optional argument is the directory, defaulting to the # current dir; second optional argument is the number of files to # show, defaulting to 20 -dir=${1:-.} lines=${2:-10} +dir=${1:-.} lim=${2:-10} # Enter the target dir or bail cd -- "$dir" || exit @@ -24,4 +24,4 @@ find . ! -name . -prune \( \ sort -k1,1nr | # Limit the output to the given number of lines -sed "$((lines))"q +awk -v lim="$lim" 'NR<=lim' -- cgit v1.2.3