Skip to content

Instantly share code, notes, and snippets.

@michal-mally
Created October 23, 2015 07:20
Show Gist options
  • Save michal-mally/b9b9a870a50a0e3ac3e6 to your computer and use it in GitHub Desktop.
Save michal-mally/b9b9a870a50a0e3ac3e6 to your computer and use it in GitHub Desktop.
def lines = new File('/Users/mmally/temp/bash_history_merged').readLines()
def entries = new TreeMap<Long, String>()
def text = lines
.collate(2)
.collectEntries(entries) { time, cmd ->
[(time - '#').toLong(), cmd]
}.collectMany { k, v ->
["#$k", v]
}.join('\n')
new File('/Users/mmally/temp/bash_history_merged_sorted').text = text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment