]> git.plutz.net Git - serve0/commitdiff
stable sort (keep name order when sorting by lenght)
authorPaul Hänsch <paul@plutz.net>
Tue, 4 Dec 2018 20:02:46 +0000 (21:02 +0100)
committerPaul Hänsch <paul@plutz.net>
Tue, 4 Dec 2018 20:02:46 +0000 (21:02 +0100)
indexmeta.sh
list.sh

index aad3fc1433990ee4f0822dc4d9b54fdd26420ed0..fb893e14195bd8ba2554adb121097a5f8c021eb9 100644 (file)
@@ -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 950522f1d302eee5a2b0dc075de4cffa7396d70c..08cef51f1cf36ff9365347774d03ab378c6050eb 100644 (file)
--- 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
 }