Skip to content

Instantly share code, notes, and snippets.

@xiaoouwang
Last active January 16, 2021 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaoouwang/31c378fa87e7623bbb468435f3591c68 to your computer and use it in GitHub Desktop.
Save xiaoouwang/31c378fa87e7623bbb468435f3591c68 to your computer and use it in GitHub Desktop.
bash command history
# 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