#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/text longest-line () { local f=$1 awk 'length > max_length { max_length = length; longest_line = $0 } END { print longest_line }' $f } longest-lines () { local f=$1 local lines=${2:-10} awk '{ print length($0) " " $0; }' $f | sort -n -r | head -n $lines } get-all-files () { local re=$1 # e.g., '*.txt', '[0-9]*' local src=$2 local dst=$3 find $src -name $re -exec cp -iv {} $dst \; } alias gandalf=get-all-files back-to-swedish () { local fs=($@) sed -e 's/=C3=A5/å/g; s/=C3=A4/ä/g; s/=C3=B6/ö/g' \ -e 's/=C3=85/Å/g; s/=C3=84/Å/g; s/=C3=96/Ö/g' \ -e 's/=20/ /g' $fs }