I turned the awk command into a function (for bash):
function shortest() { awk '(NR==1||length<shortest){shortest=length} END {print shortest}' $1 ;} ## report the length of the shortest line in a file
Added this to my .bashrc (and then "source.bashrc")
and then ran it: the shortest "yourFileNameHere"
[~] $ shortest .history
2
It can be assigned to a variable (note that reverse processing is required):
[~] $ var1 = `shortest .history`
[~] $ echo $ var1
2
For csh:
alias shortest "awk '(NR==1||length<shortest){shortest=length} END {print shortest}' \!:1 "
Bob23 source share