假设你有两个命令:
第一条命令
let foo=2+2
echo $foo
4
Run Code Online (Sandbox Code Playgroud)
第二个命令
date "%s"
1377107324
Run Code Online (Sandbox Code Playgroud)
你会如何组合它们?
尝试 1。
echo The epoch time is: `date +%s` in 100 seconds the time \
will be: `let future={date +%s}+100` $future
Run Code Online (Sandbox Code Playgroud)
尝试2。
echo The epoch time is: `date +%s` in 100 seconds the time \
will be: `let future=(date +%s)+100` $future
Run Code Online (Sandbox Code Playgroud)
加上大约 30 次其他类似的尝试
这是使用$( )而不是的重要原因` `(请参阅$(stuff) 和 `stuff` 之间的区别是什么?)
如果你像这样嵌套它,你甚至不需要let或变量:
$ echo $(date +%s) " " $(( $(date +%s)+100 ))
1377110185 1377110285
Run Code Online (Sandbox Code Playgroud)