I have a file that has repetitive entries .Entry entry starts with date , a blank line separates these two entries .How do I use sort command or uniq comand to sort the dates :
* Mon Jan 29 2001 Bernhard Rosenkraenzer <[email protected]>
- Some fixes to init scripts
* Wed Jan 17 2001 Bernhard Rosenkraenzer <[email protected]>
- Add missing man pages, fix up init script (Bug #17676)
- Can be patched in for future release.
* Thu Feb 1 2001 Trond Eivind Glomsrød <[email protected]>
- Fix check for ipchains
I used the sort command like:
sort -n -t" " -k5 -k3M -k4
but it does not captures the lines after the date , I need to sort the date+contentforthatdate.
Based on @jchevali's comment - one just needs to find a printable character that both awk and tr can handle gracefully that's not in the text to be processed:
awk '/^*/{printf "%s ^",$0} /^-/{printf "%s ^",$0} /^[ \t]*$/{printf "\n"}' paras | sort -n -t" " -k5 -k3M -k4 | tr '^' '\n'
* Wed Jan 17 2001 Bernhard Rosenkraenzer <[email protected]>
- Add missing man pages, fix up init script (Bug #17676)
- Can be patched in for future release.
* Mon Jan 29 2001 Bernhard Rosenkraenzer <[email protected]>
- Some fixes to init scripts
* Thu Feb 1 2001 Trond Eivind Glomsrød <[email protected]>
- Fix check for ipchains
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With