-
Notifications
You must be signed in to change notification settings - Fork 48
Terminal issue completed #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ricky129
wants to merge
8
commits into
cartabinaria:main
Choose a base branch
from
ricky129:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6bf2613
add: inpiù
ricky129 ebdf7a2
add: print_cheatshit
Pitots 66e748b
add: cheatsheets corso di Terminale
ricky129 13b6a34
fixed file name in print_cheatshit
Pitots 7462fb0
Merge remote-tracking branch 'refs/remotes/origin/main'
Pitots 2d010c8
add: readme && mv: print_cheatshit
Pitots df73267
rm: print_cheatshit
Pitots 2b35f51
edit: aggiunti i percorsi base ai comandi dei cheatsheets
ricky129 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| Per consultare l'elenco dei comandi del terminale basta entrare nella cartella "TerminaleIssue" ed eseguire il file "print_cheatshit.sh" |
This file contains hidden or 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,138 @@ | ||
| ### Elenca i file | ||
|
|
||
| ```sh | ||
| ls /path/to/directory | ||
| ``` | ||
|
|
||
| ### Entrare in una cartella | ||
|
|
||
| ```sh | ||
| cd /path/to/directory | ||
| ``` | ||
|
|
||
| ### Uscire da una cartella | ||
|
|
||
| ```sh | ||
| cd .. | ||
| ``` | ||
|
|
||
| ### Creare una cartella | ||
|
|
||
| ```sh | ||
| mkdir /path/to/new_directory | ||
| ``` | ||
|
|
||
| ### Creare file | ||
|
|
||
| ```sh | ||
| touch /path/to/new_file.txt | ||
| ``` | ||
|
|
||
| ### Controllare di che tipo è un file | ||
|
|
||
| ```sh | ||
| file /path/to/executable | ||
| ``` | ||
|
|
||
| ### Copiare file | ||
|
|
||
| ```sh | ||
| cp /path/to/source_file.txt /path/to/destination_directory/ | ||
| ``` | ||
|
|
||
| ### Spostare file | ||
|
|
||
| ```sh | ||
| mv /path/to/source_file.txt /path/to/destination_directory/ | ||
| ``` | ||
|
|
||
| ### Rinominare file | ||
|
|
||
| ```sh | ||
| mv /path/to/old_name.txt /path/to/new_name.txt | ||
| ``` | ||
|
|
||
| ### Eliminare file | ||
|
|
||
| ```sh | ||
| rm /path/to/file_to_delete.txt | ||
| ``` | ||
|
|
||
| ### Copiare una cartella | ||
|
|
||
| ```sh | ||
| cp -r /path/to/source_folder /path/to/destination_folder/ | ||
| ``` | ||
|
|
||
| ### Manuale di un comando | ||
|
|
||
| ```sh | ||
| man ls | ||
| ``` | ||
|
|
||
| ### Leggere un file di testo | ||
|
|
||
| ```sh | ||
| less /path/to/text_file.txt | ||
| ``` | ||
|
|
||
| ### Nano e Vim | ||
|
|
||
| ```sh | ||
| nano /path/to/file.txt | ||
| vim /path/to/another_file.txt | ||
| ``` | ||
|
|
||
| ### Contare caratteri | ||
|
|
||
| ```sh | ||
| wc -l /path/to/file.txt | ||
| ``` | ||
|
|
||
| ### Ricerca di una stringa | ||
|
|
||
| ```sh | ||
| grep "string" /path/to/file.txt | ||
| ``` | ||
|
|
||
| ### Concatenazione o lettura | ||
|
|
||
| ```sh | ||
| cat /path/to/file.txt | ||
| ``` | ||
|
|
||
| ### Testa e coda | ||
|
|
||
| ```sh | ||
| head /path/to/log_file.txt | ||
| tail -f /path/to/another_log.log | ||
| ``` | ||
|
|
||
| ### Wildcard | ||
|
|
||
| ```sh | ||
| cp *.txt /path/to/destination/ | ||
| ls -d dir* | ||
| cat file?.txt | ||
| cat *.log | ||
| ``` | ||
|
|
||
| ### Cambiare owner e group | ||
|
|
||
| ```sh | ||
| chmod 755 /path/to/script.sh | ||
| chown user:group /path/to/file.txt | ||
| chgrp group /path/to/file.txt | ||
| ``` | ||
|
|
||
| ### Pipe | ||
|
|
||
| ```sh | ||
| ls /bin | less | ||
| ``` | ||
|
|
||
| ### Ridezione su file | ||
|
|
||
| ```sh | ||
| comando > /path/to/output_file.txt | ||
| ``` |
This file contains hidden or 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,104 @@ | ||
| ### Slide della scorsa volta | ||
|
|
||
| [main.pdf](https://risorse.vercel.app/lab/2025/terminale-1/main.pdf) | ||
|
|
||
| # STDIO e ridirezioni | ||
|
|
||
| ## Output | ||
|
|
||
| Normale output di un comando, può essere visto come un file e usato su pipe e ridirezione. `>` distruttiva, `>>` appende in fondo al file. | ||
|
|
||
| ```bash | ||
| comando > /path/to/output_file.txt | ||
| ``` | ||
|
|
||
| ## Error | ||
|
|
||
| ```bash | ||
| comando_che_genera_errore > /path/to/output.txt | ||
| ``` | ||
|
|
||
| Il file `output.txt` viene creato (l’esecuzione non si ferma all’errore) ma `output.txt` non conterrà l’errore del comando perché non è `stdout`. | ||
|
|
||
| ```bash | ||
| comando_che_genera_errore > /path/to/output_and_error.txt 2>&1 | ||
| ``` | ||
|
|
||
| Ridirezionare lo `stderr` sullo stdout: `2>&1` . Non mostra messaggio di errore e ora `output_and_error.txt` contiene l’errore del comando. | ||
|
|
||
| ```bash | ||
| comando_che_genera_errore > /path/to/output.txt 2> /path/to/error_file.txt | ||
| ``` | ||
|
|
||
| Crea un file di nome `error_file.txt` e `output.txt` è vuoto. Ha preso `2> /path/to/error_file.txt` come: prendi lo `stderr` e mettilo nel file specificato. | ||
|
|
||
| ```bash | ||
| comando_che_genera_errore > /path/to/output.txt 2>/dev/null | ||
| ``` | ||
|
|
||
| Butta tutti gli errori dentro `/dev/null` e non saranno più recuperabili. | ||
|
|
||
| ## Echo | ||
|
|
||
| ```bash | ||
| echo /path/to/*/pattern | ||
| ``` | ||
|
|
||
| Stampa tutti i percorsi relativi delle sottocartelle (o cartelle) che corrispondono a `pattern` all'interno di `/path/to/`. | ||
|
|
||
| ```bash | ||
| echo {1..10} | ||
| echo {a..z} | ||
| ``` | ||
|
|
||
| Stampa tutti i numeri e caratteri in mezzo ai valori definiti. | ||
|
|
||
| ```bash | ||
| file $(ls -d /bin/* | grep utility_name) | ||
| file $(find /path/to/binaries -name "program_name" -print) | ||
| ``` | ||
|
|
||
| Il primo esempio stampa informazioni sui file che corrispondono a `utility_name` tra gli eseguibili in `/bin/`. Il secondo esempio trova il percorso di un `program_name` in `/path/to/binaries` e stampa il tipo di file. Questa sintassi è necessaria per rispettare la sintassi di `file`. | ||
|
|
||
| # Variabili | ||
|
|
||
| ```bash | ||
| set src "/path/to/source_folder" | ||
| set dest "/path/to/destination_folder" | ||
| echo "$dest" | ||
| echo "$src" | ||
| cp -r "$src" "$dest" | ||
| ls /path/to/directory | ||
| ``` | ||
|
|
||
| `set` copia i valori nelle variabili locali, e `cp` copia le cartelle ricorsivamente l’una dentro l’altra. | ||
|
|
||
| ```bash | ||
| bash -c "comando con argomenti" | ||
| ``` | ||
|
|
||
| Lancia un comando in una nuova shell. | ||
|
|
||
| Le variabili custom vengono eliminate al riavvio del computer. | ||
|
|
||
| # Shell scripting | ||
|
|
||
| Per specificare che interprete usare: | ||
|
|
||
| ```bash | ||
| #!/bin/bash | ||
| ``` | ||
|
|
||
| Specifica l’interprete da usare nella prima riga del file. Dice al terminale che stiamo creando un file di scripting. Non è necessario chiamare i file di scripting `*.sh` e definire le variabili maiuscole. | ||
|
|
||
| ```bash | ||
| #!/bin/bash | ||
| echo "Reading programs" | ||
| PROG=$(ls -d /bin/*) | ||
| NUM=$(echo "$PROG" | grep "ca" | wc -l) | ||
| echo "Number of programs containing 'ca': $NUM" | ||
| ``` | ||
|
|
||
| `NUM=$(echo "$PROG" | grep "ca" | wc -l)` stampa il contenuto di `$NUM`, che conterrà il numero di programmi che iniziano con `ca`. La variabile `$NUM` rimane locale all’esecuzione dello script, non posso neanche usare `export` perché viene trasposta ai processi figli di quel nuovo terminale creato all’inizio dello script. | ||
|
|
||
| `chmod +x /path/to/my_script.sh` permesso di esecuzione a user. |
This file contains hidden or 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,34 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Nome dello script: stampa_file_predefiniti.sh | ||
| # Descrizione: Stampa il contenuto di due file predefiniti che si trovano | ||
| # nella stessa cartella dello script. | ||
|
|
||
| # --- 1. DEFINIZIONE DEI NOMI DEI FILE --- | ||
| # Definisci qui i nomi esatti dei file che vuoi stampare. | ||
| FILE1="cheatsheetTerm1.md" | ||
| FILE2="cheatsheetTerm2.md" | ||
| # ---------------------------------------- | ||
|
|
||
| echo "Esecuzione dello script nella cartella: $(pwd)" | ||
| echo "---" | ||
|
|
||
| echo "--- 📝 Contenuto di $FILE1 ---" | ||
| if [ -f "$FILE1" ]; then | ||
| # Stampa il contenuto del primo file | ||
| cat "$FILE1" | ||
| else | ||
| echo "Errore: Il file '$FILE1' non esiste in questa cartella." | ||
| fi | ||
|
|
||
| echo "" # Aggiunge una riga vuota per separazione | ||
|
|
||
| echo "--- 📝 Contenuto di $FILE2 ---" | ||
| if [ -f "$FILE2" ]; then | ||
| # Stampa il contenuto del secondo file | ||
| cat "$FILE2" | ||
| else | ||
| echo "Errore: Il file '$FILE2' non esiste in questa cartella." | ||
| fi | ||
|
|
||
| echo "--- Fine dello script ---" |
This file contains hidden or 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 @@ | ||
| inpiù |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In tutti i comandi del primo cheatsheet mancano i path o i nomi dei file