Do somebody have idea How to sort standard input without first line which in my case it's header
Example:
Cnt|VT |STAT|Date |Time |From |Alert Message |Instance |
125| | | 260308 |160026 |ZAMUAT2|ifpollq forZAMUAT2 0 from 1 Processes Found |emeflxci |
125| | | 260308 |160026 |ZAMUAT2|/zam/edlr/bin/ifind forZAMUAT2 0 from 1 Processes Found |emeflxci |
126| | | 260308 |160026 |UGNUAT4|ugn/fts/bin/FTS_SERVER.EXE for UGNUAT4 0 from 4 Processes Found |emeflxci |
121| | | 260308 |160026 |TUNUAT4|tun/switch/bin/ifstart for TUNUAT4 0 from 1 Processes Found |emeflxci |
121| | | 260308 |160026 |TUNUAT4|ifreader_TN for TUNUAT4 0 from 1 Processes Found |emeflxci |
sed 1d file | sort >output
Reattaching the first line back on is left as an exercise, if you even want that.
This assumes that you want to sort on the first field of the file
awk 'NR==1; NR > 1 {print $0 | "sort -t\| -n -k 1,1"}' file
I want to sort all lines in input - except first [ header ] but i want header on output also.
Example file:
Time
123
1245
122134
123412
123123
1243123
12334
123123
- Time line is header
- sort by key 1reverse and numeric [ sort -k1rn ]
expected outout:
Time
1243123
123412
123123
123123
122134
12334
1245
123
If the input file has a single column then you do not need the sort by key 1
awk 'NR == 1; NR > 1 {print $0 | "sort -nr"}'
this is example, my input contain more then one column
Thanks for help, it's working
Do you know how to substitute in awk
in field $5 replace all ":" with null string?
Do you want to replace all ":" in $5 with nulls
awk 'NR==1; NR > 1 {gsub(":","",$5);print $0 | "sort -t\| -nrk 1,1"}' file