小编Sha*_*ara的帖子

带引号“$()”的变量

我写了这个脚本:

#!/bin/bash
while [ true ] 
do
    currentoutput="$(lsusb)"
    if [ "$currentoutput" != "$lastoutput" ]
    then
        echo "" date and Time >> test.log
        date +%x_r >> test.log
        lastoutput="$(lsusb)"
        lsusb >> test.log
    fi
    sleep 5
done
Run Code Online (Sandbox Code Playgroud)

我是一个试图快速学习的新手,我有一个关于变量引号的问题。

在 $() 之间放一个变量,我明白了,但为什么即使在语句中也需要引号if?是要制作嵌套命令吗?

bash scripts

13
推荐指数
1
解决办法
7901
查看次数

标签 统计

bash ×1

scripts ×1