This repository has been archived by the owner on Oct 25, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Arzigogolo 1 - 02 Ottobre 2019 | ||
|
||
## Esercizio 1 | ||
|
||
``` | ||
script --timing=file.txt | ||
``` | ||
|
||
E' possibile registrare una sessione di terminale con il programma `script`. | ||
|
||
Per salvare su un file anche i tempi di attesa tra comandi, è possibile aggiungere l'opzione `-t` / `--timing`: con essa, `script` salverà sul file specificato il tempo tra un inserimento e l'altro e i caratteri inseriti in quel tempo. | ||
|
||
## Esercizio 2 | ||
|
||
E' possibile aprire velocemente un editor di testo dalla Bash con la combinazione di comandi `Ctrl+X Ctrl+E`. | ||
|
||
Questa combinazione aprirà l'editor contenuto nella variabile `$EDITOR` (o `$VISUAL`), o, se queste variabili sono vuote/non definite, proverà ad aprire l'editor `emacs`. | ||
|
||
All'interno dell'editor, sarà presente il comando attualmente inserito dall'utente; per modificare l'ultimo comando digitato, sarà sufficiente richiamarlo premendo `Up Arrow` e premendo `Ctrl+X Ctrl+E`. | ||
|
||
## Esercizio 3 | ||
|
||
Possiamo usare le substitution di Bash per convertire tra diverse basi un dato numero. | ||
|
||
Creiamo allora due file in `/usr/bin` denominati `hex` e `dec`. | ||
|
||
Rendiamoli eseguibili con `chmod a+x hex dec`, e in essi, inseriamo i seguenti programmi: | ||
|
||
### `hex` | ||
|
||
```bash | ||
#!/bin/bash | ||
# Converti in esadecimale | ||
printf %x $1 | ||
``` | ||
|
||
### `dec` | ||
|
||
```bash | ||
#!/bin/bash | ||
# Converti in decimale | ||
echo $((16#$1)) | ||
``` |