当前位置:网站首页>Shell脚本 单引号、双引号和反引号的区别
Shell脚本 单引号、双引号和反引号的区别
2022-04-23 05:50:00 【tilblackout】
定义一个变量时,等号两边不能有空格,若有空格可用双引号或单引号将变量内容结合。
(1)双引号内的特殊字符可保有原本的特性
var="lang is $LANG"
echo $var
--输出--
lang is en_US
(2)单引号内的特殊字符仅为一般文本
var='lang is $LANG'
echo $var
--输出--
lang is $LANG
- 特殊字符(包含空格)也可用"\"转义为一般字符
(3)反引号:有的指令需要其它指令提供的信息,可用`指令`或$(指令),推荐使用后一种
version=`uname -r` 或 version=$(uname -r)
echo $version
--输出--
5.4.0-77-generic
版权声明
本文为[tilblackout]所创,转载请带上原文链接,感谢
https://blog.csdn.net/tilblackout/article/details/123411349
边栏推荐
猜你喜欢
[UDS unified diagnosis service] i. diagnosis overview (2) - main diagnosis protocols (K-line and can)
OpenCV使用 GenericIndex 进行 KNN 搜索
Robocode教程8——AdvancedRobot
[UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit
copy constructor
大学概率论与数理统计知识点详细整理
Swagger2 generates API documents
Qt 给应用程序加图标
Class inheritance and derivation
【UDS统一诊断服务】一、诊断概述(1)— 诊断概述
随机推荐
对象的动态建立和释放,赋值和复制
【UDS统一诊断服务】四、诊断典型服务(5)— 功能/元件测试功能单元(例行程序功能单元0x31)
[UDS unified diagnostic service] IV. typical diagnostic service (5) - function / component test function unit (routine function unit 0x31)
[stepping on the pit] MELD in win11 wsl2 cannot be used normally. Problem repair
vs中能编译通过,但是会有红色下划线提示未定义标示符问题
Feign请求日志统一打印
【无标题】
[ThreadX] h743 + ThreadX + Filex migration record
类和对象
selenium+PhantomJS破解滑动验证2
四元数乘法
[UDS unified diagnosis service] i. diagnosis overview (2) - main diagnosis protocols (K-line and can)
[UDS unified diagnostic service] II. Network layer protocol (2) - data transmission rules (single frame and multi frame)
PM2 deploy nuxt related commands
静态成员
日志写法(带时间)
[UDS unified diagnosis service] i. diagnosis overview (1) - diagnosis overview
Protection of shared data
Opencv uses genericindex for KNN search
Wechat applet request encapsulation