当前位置:网站首页>shell学习记录(二)
shell学习记录(二)
2022-06-26 00:24:00 【_Bruce】
read:
read 命令从标准输入中读取一行,并把输入行的每个字段的值指定给 shell 变量
#!/bin/sh
read name
read name1
echo "$name It is a test"
echo "$name1 It is a test1"以上代码保存为 test.sh,name 接收标准输入的变量,结果将是:
[[email protected] ~]# sh test.sh
OK #标准输入
OK1
OK It is a test #输出
OK1 It is a test #输出显示不换行:
echo -e "OK! \c" # -e 开启转义 \c 不换行显示结果定向至文件:
echo "It is a test" > myfile原样输出字符串,不进行转义或取变量(用单引号)
a=100
echo '$a'输出:
$a显示命令执行结果:
echo `date`注意: 这里使用的是反引号 `, 而不是单引号 '。
结果将显示当前日期
2020年 9月 2日 星期三 21时07分18秒 CSTprintf的转义序列:


Shell test 命令:
test命令一般都可以转换为中括号加表达式:[ 表达式 ]

#!/bin/bash
num1=100
num2=100
if [ $num1 -eq $num2 ]
then
echo "两个数相等"
else
echo "两个数不相等"
fi
if test $[num1] -eq $[num2]
then
echo "两个数相等"
else
echo "两个数不相等"
fi
输出:
两个数相等
两个数相等下边还有字符串运算符、文件测试运算符就不一一列举了
边栏推荐
- 丨EGFR FISH 探针解决方案
- 程序 编译的步骤 预编译 编译 汇编 连接
- Sweet girl lisixia was invited to be the little host of the global finals of the sixth season perfect child model
- Sunshine boy chenhaotian was invited to be the spokesperson for the global finals of the sixth season perfect children's model
- PTA class a simulated fifth bomb: 1148-1151
- Easyexcel read file
- Cs144 environment configuration
- regular expression
- cyclegan:unpaired image-to-image translation using cycle-consistent adversarial network
- About vs scanf, 'scanf' appears: this function or variable may be unsafe Solutions to the problem of consumer usi
猜你喜欢

biggan:large scale gan training for high fidelity natural image synthesis

V4L2+QT视频优化策略

Redis7.0 installation steps

二造实务案例答题技巧和举例汇总,满满都是精髓

The answer skills and examples of practical cases of the second construction company are full of essence

Abnova丨ACTN4 DNA 探针解决方案

Distributed systems (II) understanding of distributed transactions

readv & writev

recvmsg & sendmsg

Tengwenze, a hot-blooded boy, was invited to serve as the image ambassador of the global finals of the sixth season perfect children's model
随机推荐
Abnova actn4 DNA probe solution
Dataframe to list
甜酷少女金书伊 受邀担任第六季完美童模全球总决赛代言人
Gun make (5) variables in makefile
如何制定一个可实现的年度目标?
Gun make (7) execute make
Playful girl wangyixuan was invited to serve as the Promotion Ambassador for the global finals of the sixth season perfect children's model
接口测试用例设计
UN make (6) conditional execution of makefile
PTA class a simulated third bomb: 1140-1143
一分钟了解同步、异步、阻塞和非阻塞的区别
Sunshine boy chenhaotian was invited to be the spokesperson for the global finals of the sixth season perfect children's model
Find the multiplication order of n
Command of gun make (4) rule
buffer
Brief introduction to the usage of iloc in dataframe
Mot - clé C facile à comprendre statique
biggan:large scale gan training for high fidelity natural image synthesis
如何为政企移动办公加上一道“安全锁”?
Wanglaoji pharmaceutical's public welfare activity of "caring for the most lovely people under the scorching sun" was launched in Hangzhou