From d1e7e3c7931410f6705f7f89f03c580380a354f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Tue, 4 Dec 2018 21:02:46 +0100 Subject: [PATCH] stable sort (keep name order when sorting by lenght) --- indexmeta.sh | 6 +++--- list.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/indexmeta.sh b/indexmeta.sh index aad3fc1..fb893e1 100644 --- a/indexmeta.sh +++ b/indexmeta.sh @@ -52,9 +52,9 @@ meta_purge(){ name="$(meta_name "$file")" if [ -d "${meta%/meta}" ] && LOCK "$meta"; then - grep -avF " ${name}" "$meta" >"$meta.tmp" - grep -aF " ${name}" "$meta" >>"$meta.trash" - mv "$meta.tmp" "$meta" + grep -avF " ${name}" "$meta" >"${meta}.tmp" + grep -aF " ${name}" "$meta" >>"${meta}.trash" + mv "${meta}.tmp" "$meta" RELEASE "$meta" fi } diff --git a/list.sh b/list.sh index 950522f..08cef51 100644 --- a/list.sh +++ b/list.sh @@ -122,9 +122,9 @@ list_order(){ fi ln="$name" done \ - | sort -n -k1 |cut -f2- |sed 's;^;metashort\t;;' + | sort -sn -k1 |sed -r 's;^[0-9]+\t;metashort\t;;' elif [ $ORDER = Length ]; then - sort -n -k1 |sed 's;^;metashort\t;;' + sort -sn -k1 |sed 's;^;metashort\t;;' elif [ $ORDER = Date ]; then while read -r fm; do sn="${fm##* }" @@ -132,7 +132,7 @@ list_order(){ printf '%i %s %s\n' \ "$(stat -c %Y "$fn")" "${fm% *}" "$fn" done \ - | sort -rn -k1 |sed -r 's;^[0-9]+\t;metalong\t;;' + | sort -srn -k1 |sed -r 's;^[0-9]+\t;metalong\t;;' fi } -- 2.39.2