有两种方法可以将命令输出赋给变量:
反引号字符 `
testing='date'
$()格式
testing=$(date)
#!/bin/bash
# copy the /usr/bin directory listing to a log file
today=$(date +%y%m%d%k%M%S)
ls /usr/bin -al > log.$today
使用Shell脚本捕获命令输出并保存到变量
有两种方法可以将命令输出赋给变量:
反引号字符 `
testing='date'
$()格式
testing=$(date)
#!/bin/bash
# copy the /usr/bin directory listing to a log file
today=$(date +%y%m%d%k%M%S)
ls /usr/bin -al > log.$today

被折叠的 条评论
为什么被折叠?