mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-03-22 19:02:44 +00:00
Update cheatsheets
This commit is contained in:
41
histexpand
Normal file
41
histexpand
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
syntax: markdown
|
||||
tags: [tldr, common]
|
||||
source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# history expansion
|
||||
|
||||
> Reuse and expand the shell history in `sh`, `bash`, `zsh`, `rbash` and `ksh`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/html_node/History-Interaction>.
|
||||
|
||||
- Run the previous command as root (`!!` is replaced by the previous command):
|
||||
|
||||
`sudo !!`
|
||||
|
||||
- Run a command with the last argument of the previous command:
|
||||
|
||||
`{{command}} !$`
|
||||
|
||||
- Run a command with the first argument of the previous command:
|
||||
|
||||
`{{command}} !^`
|
||||
|
||||
- Run the Nth command of the history:
|
||||
|
||||
`!{{n}}`
|
||||
|
||||
- Run the command `n` lines back in the history:
|
||||
|
||||
`!-{{n}}`
|
||||
|
||||
- Run the most recent command containing `string`:
|
||||
|
||||
`!?{{string}}?`
|
||||
|
||||
- Run the previous command, replacing `string1` with `string2`:
|
||||
|
||||
`^{{string1}}^{{string2}}^`
|
||||
|
||||
- Perform a history expansion, but print the command that would be run instead of actually running it:
|
||||
|
||||
`{{!-n}}:p`
|
||||
Reference in New Issue
Block a user