当前位置:网站首页>Shell learning record (II)
Shell learning record (II)
2022-06-26 02:04:00 【_ Bruce】
read:
read Command to read a line from standard input , And assign the value of each field of the input line to shell Variable
#!/bin/sh
read name
read name1
echo "$name It is a test"
echo "$name1 It is a test1"The above code is saved as test.sh,name Receive standard input variables , The result will be :
[[email protected] ~]# sh test.sh
OK # The standard input
OK1
OK It is a test # Output
OK1 It is a test # Output Show no line breaks :
echo -e "OK! \c" # -e Open escape \c Don't wrap Show results directed to file :
echo "It is a test" > myfileOutput string as is , Do not escape or take variables ( single quote )
a=100
echo '$a'Output :
$aShow command execution results :
echo `date`Be careful : It's back quotes here `, Not single quotes '.
The result will show the current date
2020 year 9 month 2 Japan Wednesday 21 when 07 branch 18 second CSTprintf The escape sequence of :


Shell test command :
test Commands can generally be converted to brackets and expressions :[ expression ]

#!/bin/bash
num1=100
num2=100
if [ $num1 -eq $num2 ]
then
echo " Two numbers are equal "
else
echo " The two numbers are not equal "
fi
if test $[num1] -eq $[num2]
then
echo " Two numbers are equal "
else
echo " The two numbers are not equal "
fi
Output :
Two numbers are equal
Two numbers are equal There is also a string operator below 、 File test operators are not listed one by one
边栏推荐
- PTA class a simulated sixth bomb: 1156-1159
- SDRAM控制器——添加读写FIFO
- 17.11 std:: atomic continuation, std:: async in-depth discussion
- 记录一个诡异的图片上传问题
- 影响个人成长的三个因素
- Sweet girl lisixia was invited to be the little host of the global finals of the sixth season perfect child model
- The 19th - 22nd week of scientific research training - about tnet and memnet
- Dataframe to list
- Introduction to gun make (1)
- PTA class a simulated second bullet: 1136-1139
猜你喜欢

One stop solution EMQ for hundreds of millions of communication of Internet of things

前置++,后置++与前置--与后置--(++a,a++与--a,a--)

CyCa children's physical etiquette Yueqing City training results assessment successfully concluded

Visual studio 2013 redistributable is installed, but MySQL installation fails

Distributed systems (II) understanding of distributed transactions

图形渲染管线

Sweet cool girl jinshuyi was invited to be the spokesperson for the global finals of the sixth season perfect children's model

The 19th - 22nd week of scientific research training - about tnet and memnet

初识Opengl

tos cos dscp 区别和作用
随机推荐
Redis的使用
Tcp网络通信中各个状态的含义
Characteristics and related specificity of Papain
如何高效的完成每日的任务?
Brief introduction to the usage of iloc in dataframe
cyclegan:unpaired image-to-image translation using cycle-consistent adversarial network
xargs 的作用详解
PTA class a simulated seventh bomb: 1160-1163
PTA class a simulated 8th bomb: 1164-1167
螺旋矩阵
Abnova actn4 DNA probe solution
Application and chemical properties of elastase
cv==biaoding---open----cv001
shell学习记录(一)
轻轻松松理解指针
Redis-链表
Three factors affecting personal growth
前置++,后置++与前置--与后置--(++a,a++与--a,a--)
如何制定可实现中长期目标?
字节序问题