"$()" 或 `` 未正确扩展 shell 脚本中的 linux 命令
"$()" or `` is not properly expanding the linux command in shell script
我的代码片段有如下回显行:
echo "$(wc -l prov_bulk) provisioning commands found between $t_stmp1 of $(head -1 file_list) till $t_stmp2 of $(tail -1 file_list)"
预期输出:
1054721 provisioning commands found between 2017033023 of 170330.AUG till 2017033102 of 170331.AUG
输出得到:
1054721 prov_bulk provisioning commands found between 2017033023 of 170330.AUG till 2017033102 of 170331.AUG
为什么文件名 "prov_bulk" 也出现了?如何摆脱这个?
只需添加一个 <
即可解决您的问题。重定向省略了文件名。
echo "$(wc -l < prov_bulk) provisioning commands found between $t_stmp1 of $(head -1 file_list) till $t_stmp2 of $(tail -1 file_list)"
我的代码片段有如下回显行:
echo "$(wc -l prov_bulk) provisioning commands found between $t_stmp1 of $(head -1 file_list) till $t_stmp2 of $(tail -1 file_list)"
预期输出:
1054721 provisioning commands found between 2017033023 of 170330.AUG till 2017033102 of 170331.AUG
输出得到:
1054721 prov_bulk provisioning commands found between 2017033023 of 170330.AUG till 2017033102 of 170331.AUG
为什么文件名 "prov_bulk" 也出现了?如何摆脱这个?
只需添加一个 <
即可解决您的问题。重定向省略了文件名。
echo "$(wc -l < prov_bulk) provisioning commands found between $t_stmp1 of $(head -1 file_list) till $t_stmp2 of $(tail -1 file_list)"