Last active
May 5, 2022 01:15
-
-
Save cornfeedhobo/ba1a271f2b30f7bfc3100a5ad33be300 to your computer and use it in GitHub Desktop.
Sort bash history files with timestamps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Example usage: | |
# cat hosts/*/.bash_history | sort-timestamp-history > merged_history | |
exec \ | |
sed \ | |
-e '/^$/d' \ | |
-e '/^#/N' \ | |
-e '/^#/!s/^/#0\n/' \ | |
-e 's/#//' \ | |
-e 'y/\n/ /' \ | |
- | | |
sort -uk2 | | |
sort -n | | |
sed -e 's/\(\S\+\) /#\1\n/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment