-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand_minishell_Correction
More file actions
167 lines (146 loc) · 4.18 KB
/
Command_minishell_Correction
File metadata and controls
167 lines (146 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
## BLOCCO 1 — SIMPLE COMMAND & GLOBAL
- /bin/ls
- [Invio]
- [Spazi] + Invio
- [Tab] + Invio
- /bin/ls → echo $?
- /bin/nonexistent → echo $?
- exit 256 → echo $?
## BLOCCO 2 — ARGUMENTS & HISTORY
- /bin/ls -l
- /bin/echo hello world
- /usr/bin/env
- /bin/grep include minishell.h
- [Esegui comandi] → freccia ↑ ↓
- Ripeti comando da history → Invio
## BLOCCO 3 — ECHO
- echo
- echo ciao mondo
- echo -n
- echo -nnnnn ciao
- echo ciao mondo -n
- echo "ciao mondo"
- echo " con spazi "
- echo "$USER"
- echo '$USER'
## BLOCCO 4 — EXIT
- exit
- exit 0
- exit 42
- exit 256 → echo $?
- exit pippo → echo $?
- exit 10 pippo → echo $?
## BLOCCO 5 — RETURN VALUE OF A PROCESS
- /bin/ls → echo $?
- /bin/ls -l → echo $?
- /bin/echo hello > file.txt → echo $?
- /bin/nonexistent → echo $?
- /bin/ls filethatdoesntexist → echo $?
- /bin/false → expr $? + $?
- /bin/ls → /bin/nonexistent → expr $? + $?
- echo $(expr 2 + 3)
## BLOCCO 6 — SIGNALS
- Ctrl-C a prompt vuoto
- Ctrl-\ a prompt vuoto
- Ctrl-D a prompt vuoto
- ls -l (non inviare) → Ctrl-C → Invio
- echo cia (non inviare) → Ctrl-D
- echo cia (non inviare) → Ctrl-\
- cat → Ctrl-C
- cat → Ctrl-\
- cat → Ctrl-D
## BLOCCO 7 — DOUBLE QUOTES
- echo "Hello World"
- echo "This is a test"
- echo "This is a test with multiple words"
- echo "cat lol.c | cat > lol.c"
- export USER=Ilaria → echo "Hello $USER!"
- echo "Path: $PATH"
- echo "Test output" > output.txt → cat output.txt
- echo "cat file.txt | grep 'pattern' > output.txt"
## BLOCCO 8 — SINGLE QUOTES
- echo '$USER'
- echo '$HOME'
- echo '$USER | grep test'
- echo '$USER > output.txt'
- echo '$USER | grep $USER > output.txt'
- echo ''
- echo 'Hello world, $USER'
- echo '$USER | echo "Test"'
- echo '$HOME/$USER'
## BLOCCO 9 — ENV
- env
- export TEST_VAR=ciao → env | grep TEST_VAR
- export TEST_VAR=mondo → env | grep TEST_VAR
- export EMPTY_VAR= → env | grep EMPTY_VAR
- export SOLO_NOME → env | grep SOLO_NOME → export
## BLOCCO 10 — EXPORT
- export MY_VAR=ciao → env | grep MY_VAR
- export MY_VAR=mondo → env | grep MY_VAR
- export EMPTY_VAR= → env | grep EMPTY_VAR
- export SOLO_NOME → env + export
- unset MY_VAR → env | grep MY_VAR
- export MY_VAR=nuovo_valore → env | grep MY_VAR
- export 1NOTVALID=ciao
## BLOCCO 11 — UNSET
- export TEST_VAR=ciao → unset TEST_VAR → env | grep TEST_VAR
- export A=1 → export B=2 → unset A B → env | grep A/B
- unset XYZ
- unset 123ABC
## BLOCCO 12 — CD
- cd /tmp → /bin/pwd
- cd .. → /bin/pwd
- cd . → /bin/pwd
- cd → /bin/pwd
- cd /this/path/does/not/exist
- cd dir1 dir2
- cd /tmp → echo $PWD
## BLOCCO 13 — PWD
- pwd
- cd / → pwd
- cd /tmp → pwd
- cd .. → pwd
- pwd → pwd → pwd
## BLOCCO 14 — RELATIVE PATH
- cd /bin → ./ls
- cd / → ./bin/ls
- cd /bin → ../bin/ls
- cd /usr/bin → ../../bin/ls
- cd /bin → ./nonexistent
- cd /; cd usr; cd ..; ./bin/ls
## BLOCCO 15 — ENVIRONMENT PATH
- ls
- unset PATH → ls
- export PATH=/bin → ls
- export PATH=/tmp:/bin → ls (fake ls)
- export PATH=/bin:/tmp → ls
- export PATH=[default value] - export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
## BLOCCO 16 — REDIRECTIONS
- echo "hello world" > test1.txt → cat test1.txt
- cat < test1.txt
- echo "second line" >> test1.txt → cat test1.txt
- cat < file1 < file2
- cat < test1.txt > test2.txt → cat test2.txt
- cat << EOF ... EOF
- grep hello << END ... END
- ls > out.txt → wc < out.txt
- cat < file_che_non_esiste.txt
- echo hello>file.txt → cat<file.txt
## BLOCCO 17 — PIPES
- cat file.txt | grep hello
- cat file.txt | grep hello | wc -l
- ls file_inesistente | grep bla | wc -l
- cat file.txt | grep hello > risultato.txt
- grep hello < file.txt | wc -l
- cat file.txt | grep hello >> out.txt
- < file.txt grep hello | wc -l
- cat file.txt | grep hello > nuovo.txt
- cat | grep hello → (Ctrl+D dopo input)
- < file.txt grep hello | sort | uniq > final.txt
- echo -e "ciao\nciao\nok" | uniq
- ls | comando_che_non_esiste | wc -l
## BLOCCO 18 — GO CRAZY & HISTORY
- ls -la (non invio) → Ctrl-C → Invio
- echo hello → pwd → ↑↓ navigation
- dsbksdgbksdghsd
- echo aaaa bbbb ... (molti argomenti)