我想使用bash脚本显示某些细节,但bash脚本的输出与终端的输出不同。bash脚本的格式输出
端子输出:
[email protected]:~/ubin$ cat schedule.text | grep 09/06/12
Sat 09/06/12 Russia 00:15 Czech Republic A
Sat 09/06/12 Netherlands 21:30 Denmark B
[email protected]:~/ubin$
bash脚本输出:
[email protected]:~/ubin$ bash fixture.sh
Sat 09/06/12 Russia 00:15 Czech Republic A Sat 09/06/12 Netherlands 21:30 Denmark B
[email protected]:~/ubin$
正如可以看到bash脚本的输出从端子的输出不同。我的bash脚本输出包含了一行代码。
fixture.sh:
A=$(date +%d/%m/%y) #get today's date in dd/mm/yy fmt
fixture=$(cat /home/ubuntu/ubin/schedule.text | grep $A)
echo $fixture
所以,我的问题是如何让我的bash脚本输出类似于终端输出?
OK'双quotes'的伎俩。你可以提供一些细节,或者指出正确的“双引号”技巧文档。 – ronnie
感谢您的解释。将在6分钟内接受答案。 – ronnie