Back (Current repo: scraps)

random scraps and notes that are useful to me
To clone this repository:
git clone https://git.viktor1993.net/scraps.git
Log | Download | Files | Refs

commit b9e8ca8578a0fe591b1ffaebd45216e99ad566e3
parent 5f0e5b3255b062a2abac37f37b7bd62657157379
Author: root <root>
Date:   Mon,  6 Jul 2026 17:57:40 +0200

new awk snippet

Diffstat:
Aawk/sort_by_biggest.awk | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/awk/sort_by_biggest.awk b/awk/sort_by_biggest.awk @@ -0,0 +1,20 @@ +#!/bin/awk -f +{ + arr[NR] = $0; +} +END{ + for(i = 1; i<=NR; i++) { + for(j=i+1; j<=NR; j++){ + my_i=substr(arr[i], 1, index(arr[i], "\t") - 1)+0; + my_j=substr(arr[j], 1, index(arr[j], "\t") - 1)+0; + if (my_i < my_j) { + tmp=arr[i]; + arr[i]=arr[j]; + arr[j]=tmp; + } + } + } + for(i=1; i<=NR; i++) { + print arr[i]; + } +}