Skip to content

Instantly share code, notes, and snippets.

@theJian
Created September 14, 2016 15:05
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 theJian/1aa18793b61378857aac79e7ae3f4116 to your computer and use it in GitHub Desktop.
Save theJian/1aa18793b61378857aac79e7ae3f4116 to your computer and use it in GitHub Desktop.
bash tips
# last command
!!
# last command beginning with xyz
!xyz
# print rather than excuting last command
!!:p
# the end of previous command
!$
# All of the arguments of the previous command
!*
# fix typo
mroe filename # wrong
^ro^or # trun into more filename
^error^correction
# brace expression
touch a{1,2,3}b # touch a1b a2b a3b
# Remove a trailing file name component, leaving only the head.
:h
# Remove all leading file name components, leaving the tail.
:t
# Remove a trailing suffix of the form .xxx, leaving the basename.
:r
# Remove all but the trailing suffix.
:e
# Substitution
:s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment