tipsshell: ajouter history expansion
This commit is contained in:
parent
0bb95cf4d2
commit
f068477c3c
28
TipsShell.md
28
TipsShell.md
|
@ -148,6 +148,34 @@ $ sed 's/^/Coucou /g' <<<"$VAR"
|
|||
$ (for host in machine1 machine2 ...; do echo $host; timeout -k 2 2 ssh -o 'StrictHostKeyChecking no' $host cat /etc/ssh/ssh_host_dsa_key.pub >> ~/.ssh/known_hosts; done)
|
||||
~~~
|
||||
|
||||
## Manipuler l’historique
|
||||
|
||||
Les éléments suivants permettent de rappeler des bouts des commandes précédentes. Voir la section [_History Expansion_(https://www.gnu.org/software/bash/manual/bash.html#History-Interaction) dans le manuel de Bash.
|
||||
|
||||
* `!!` : la dernière commande
|
||||
* `!-2` : l’avant dernière commande
|
||||
* `!$` : le dernier argument de la dernière commande
|
||||
* `!:2` : le deuxième argument de la dernière commande
|
||||
* `^old^new^` : le dernière commande, en remplaçant `old` par `new`
|
||||
|
||||
> Lorsque qu’on entre une commande qui utilise l’_history expansion_, Bash affiche la commande qui est vraiment exécuté juste après le _prompt_.
|
||||
|
||||
Exemple :
|
||||
|
||||
~~~
|
||||
$ echo a b c
|
||||
a b c
|
||||
$ echo !! d
|
||||
echo echo a b c d
|
||||
echo a b c d
|
||||
$ ^d^D^
|
||||
echo echo a b c D
|
||||
echo a b c D
|
||||
$ echo !:2 !$
|
||||
echo a D
|
||||
a D
|
||||
~~~
|
||||
|
||||
# Fichiers et FS
|
||||
|
||||
## Ordinaire
|
||||
|
|
Loading…
Reference in New Issue