19
0
Fork 0

tipsshell: ajouter history expansion

This commit is contained in:
Alexis Ben Miloud--Josselin 2022-11-16 11:33:35 +01:00
parent 0bb95cf4d2
commit f068477c3c
1 changed files with 28 additions and 0 deletions

View File

@ -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 lhistorique
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` : lavant 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 quon 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