Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 911 Bytes

bash.md

File metadata and controls

50 lines (38 loc) · 911 Bytes
  1. Help
  2. History
  3. Several commands
  4. if-else
  5. loop
  6. read file

Help

man bash

man builtin

# help on builtin command 'history'
help history

History

# show last N commands from bash history
history N
!!   repeat the previous line

# arguments
!*   all arguments
!:0  the command
!^   first argument
!$   last argument
!:N  N-th argument

!:2-4   2 to 4 arguments
!:2-$   2 to last arguments
!:2*    2 to last arguments
!:2-    2 to next to last arguments

Several commands

  • A; B - run A and then run B, regardless of A failed or succeeded
  • A && B - run A and if A succeeded then run B
  • A || B - run A and if A failed then run B
  • A & - run A in background
  • (A ; B) - concatenate output of A and B
  • (cd A ; ls -lh) - change directory to A and perform ls without changing directory