English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The echo command in Shell is similar to the echo command in PHP, both of which are used for string output. Command format:
echo string
You can use echo to implement more complex output format control.
echo "It is a test"
The double quotes can be omitted here. The following command has the same effect as the above example:
echo It is a test
echo \
The result will be:
"It is a test"
Anche le virgolette doppie possono essere omesse
Il comando read legge una riga dall'input standard e assegna il valore di ogni campo al variabile shell
#!/bin/sh read name echo "$name It is a test"
Il codice sopra deve essere salvato come test.sh, la variabile name riceve il valore dell'input standard, il risultato sarà:
[root@www ~]# sh test.sh OK # Input standard OK It is a test # Output
echo -e "OK! \n" # -e abilita l'escapamento echo "It is a test"
Risultato di output:
OK! It is a test
#!/bin/sh echo -e "OK! \c" # -e abilita l'escapamento \c non a capo echo "It is a test"
Risultato di output:
OK! It is a test
echo "It is a test" > myfile
echo '$name\"'
Risultato di output:
$name\"
echo `date`
Attenzione: Qui viene utilizzato l'apice `, invece dell'apice singolo '。
I risultati verranno visualizzati con la data corrente
Gio 24 Lug 10:08:46 CST 2018