Hello, I often find that I want to keep one or a few lines untouched by sort, and end up using something like this:
$ awk 'NR == 1; NR > 1 { print $0 | "sort" }' It would be handy if sort had an option for 'number of heading lines' or similar! I imagine something like this: $ sort -H # keeps first line in place while sorting the rest Or maybe keep it generic: $ sort -H 3 # keeps first 3 lines in place while sorting the rest Concrete use case: $ kubectl get pod -A -o wide | awk 'NR == 1; NR > 1 { print $0 | "sort -k 7" }' NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES foo foo-gui-7bc9944686-5q6wr 1/1 Running 0 40m 10.0.0.13 aks-private-30529318-vmss000000 <none> <none> bar bar-internal-ws-f7c95c569-zzxrz 1/1 Running 0 40m 10.0.0.14 aks-private-30529318-vmss000000 <none> <none> foo foo-psql-7d7ff9b7b8-4gw9k 1/1 Running 1 40m 10.0.0.15 aks-private-30529318-vmss000000 <none> <none> baz baz-internal-ws-7c8dd8875b-b8nsk 1/1 Running 0 40m 10.0.0.19 aks-private-30529318-vmss000000 <none> <none> foo foo-admin-67fc4fcfc4-8z8l9 1/1 Running 0 40m 10.0.0.23 aks-private-30529318-vmss000000 <none> <none> baz baz-psql-56fb65b5cd-c5d5l 1/1 Running 1 40m 10.0.0.32 aks-private-30529318-vmss000000 <none> <none> bar bar-psql-5cb8fd99b-mljq2 1/1 Running 1 40m 10.0.0.33 aks-private-30529318-vmss000000 <none> <none> kube-system calico-node-6ll4z 1/1 Running 0 17h 10.0.0.4 aks-private-30529318-vmss000000 <none> <none> kube-system kube-proxy-wwc87 1/1 Running 0 16h 10.0.0.4 aks-private-30529318-vmss000000 <none> <none> foo foo-internal-ws-86498bb864-pvrl2 1/1 Running 0 40m 10.0.0.7 aks-private-30529318-vmss000000 <none> <none> qux qux-psql-5d66ff54f6-fpwj7 1/1 Running 1 40m 10.1.0.14 aks-veryprivate-30529318-vmss000000 <none> <none> quux quux-universal-ws-5d88c9967b-7km4n 1/1 Running 0 40m 10.1.0.17 aks-veryprivate-30529318-vmss000000 <none> <none> quux spec-universal-ws-5b4c49f98d-48bb7 1/1 Running 0 40m 10.1.0.20 aks-veryprivate-30529318-vmss000000 <none> <none> quux quux-psql-86567f96d8-nx2xl 1/1 Running 1 40m 10.1.0.23 aks-veryprivate-30529318-vmss000000 <none> <none> qux qux-internal-ws-c48868467-mvhkc 1/1 Running 0 40m 10.1.0.30 aks-veryprivate-30529318-vmss000000 <none> <none> kube-system calico-node-l4kfm 1/1 Running 0 17h 10.1.0.4 aks-veryprivate-30529318-vmss000000 <none> <none> kube-system kube-proxy-294vn 1/1 Running 0 16h 10.1.0.4 aks-veryprivate-30529318-vmss000000 <none> <none> quux-proxy quux-proxy-79fb4757cb-2jzr5 1/1 Running 0 40m 10.2.0.29 aks-public-30529318-vmss000000 <none> <none> foo-proxy foo-proxy-569857f898-x2rv4 1/1 Running 0 40m 10.2.0.34 aks-public-30529318-vmss000000 <none> <none> kube-system calico-node-mr6nf 1/1 Running 0 17h 10.2.0.4 aks-public-30529318-vmss000000 <none> <none> kube-system kube-proxy-r76r6 1/1 Running 0 17h 10.2.0.4 aks-public-30529318-vmss000000 <none> <none> kube-system kubernetes-dashboard-cc4cc9f58-hpncw 1/1 Running 2 17h 10.4.0.16 aks-untainted-30529318-vmss000000 <none> <none> kube-system coredns-7fc597cc45-b9jbv 1/1 Running 0 17h 10.4.0.20 aks-untainted-30529318-vmss000000 <none> <none> kube-system tunnelfoo-5d96bdcb54-wxbsb 1/1 Running 0 17h 10.4.0.21 aks-untainted-30529318-vmss000000 <none> <none> kube-system calico-typha-horizontal-autoscaler-77df4784d7-hhl6g 1/1 Running 0 17h 10.4.0.22 aks-untainted-30529318-vmss000000 <none> <none> kube-system coredns-autoscaler-7ccc76bfbd-d42xk 1/1 Running 0 17h 10.4.0.25 aks-untainted-30529318-vmss000000 <none> <none> kube-system coredns-7fc597cc45-gkf46 1/1 Running 1 17h 10.4.0.31 aks-untainted-30529318-vmss000000 <none> <none> kube-system metrics-server-58b6fcfd54-4t28d 1/1 Running 2 17h 10.4.0.33 aks-untainted-30529318-vmss000000 <none> <none> kube-system calico-node-6z8rs 1/1 Running 0 17h 10.4.0.4 aks-untainted-30529318-vmss000000 <none> <none> kube-system calico-typha-6b998f8fd7-clzh7 1/1 Running 0 17h 10.4.0.4 aks-untainted-30529318-vmss000000 <none> <none>