Last active
January 16, 2021 10:24
-
-
Save xiaoouwang/31c378fa87e7623bbb468435f3591c68 to your computer and use it in GitHub Desktop.
bash command history
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
# Author: Xiaoou Wang, Master’s student in natural language processing looking for a phd position/contrat cifre. | |
# https://xiaoouwang.medium.com/get-readable-bash-command-history-with-cut-and-vscode-4eb8d56f38b4 | |
history | tail -n 15 # show the last 15 commands | |
echo "abcdefghi" | cut -c2-6 # extract the 2nd to the 6th character | |
# output = bcdef | |
echo "a-b-c" | cut -d'-' -f2 # split the string into 3 parts and get the 2nd part | |
# output = b | |
history | cut -d' ' -f4- | tail -n 15 # separate using space, get the 4th to nth column, get the last 15 commands | |
history | cut -d' ' -f4- | tail -n 15 | code - # show the results in vsc | |
history | grep “python” | cut -d' ' -f 4- | tail -n 15 | code - # Seach a command containing specific string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment