我写了这个脚本:
#!/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?是要制作嵌套命令吗?