------------------------------------------------------------------------ Header lines ------------------------------------------------------------------------ It is a standard problem: you have a data file with header. You want to manipulate the data file (e.g. sort on a column) but not the header line. ------------------------------------------------------------ Ia. Adding a header line to a date file (table.dat) ------------------------------------------------------------ $ echo -e "Column:RA Column:Dec Column:Mag" | cat - table.dat > table_with_hdr $ sed '1i Column:RA Column:Dec Column:Mag' table > table_with_hdr ------------------------------------------------------------ Ib. Replace table.dat with a file which has header ------------------------------------------------------------ $ sed -it '1i Column:RA Column:Dec Column:Mag' table $ echo -e "Column:RA Column:Dec Column:Mag" | cat - table.dat | tee table.dat (quite clever and not obvious) ------------------------------------------------------------ II. Analyze whilst ignoring header ------------------------------------------------------------ Assume that table.dat has a header line. Say you wanto numerically reverse sort on column 1. $ head -n 1 table.dat && tail -n +2 table | sort -nr -k1 $ head -n1 table.dat; tail -n +2 table | sort -nr -k1 $ awk 'NR<2{print $0;next}{print $0| "sort -nr -k1"}' $ awk'NR==1;NR>1{print $0| "sort -nr -k1"}' ------------------------------------------------------------------------ III. The BEST solution ------------------------------------------------------------------------ $ cat a.dat Header 1 2 3 $ (header -n1; sort -knr)