This sorts lines 6 and after the file, leaving the first 5 lines unchanged:
{ head -n5 file.txt; tail -n+6 file.txt | sort -ft$ -k2n,2; } >file.tmp && mv file.tmp file.txt
Tcsh
Unlike bash, kshand zsh, tcshdoes not support grouping commands with {...}. Instead, try a subshell:
( head -n5 file.txt; tail -n+6 file.txt | sort -ft$ -k2n,2 ) >file.tmp && mv file.tmp file.txt
source
share