# shell脚本之echo命令

echo 命令用于字符串的输出

echo "hello world"

hello world

# 显示转义字符
echo "\"hello world\""

"hello world"

# 显示变量
read name
echo "$name It is a test"

# 显示换行
echo -e "OK! \n" # -e 开启转义
echo "It is a test"

# 显示不换行
echo -e "OK! \c" # -e 开启转义 \c 不换行
echo "It is a test"

# 将字符串添加至文件末尾
echo "hello world" >> test.txt

# 原样输出字符串,不进行转义或取变量(用单引号)
echo '$name\"'

$name\"

# 显示命令执行结果
echo `date`
Mon Sep 2 10:36:36 AM UTC 2024
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
上次更新: 9/2/2024, 6:59:44 PM