首页 > 解决方案 > 如何将文件名与变量一起导出?

问题描述

我的代码是:

a = 5335672
cat 1.txt 2.txt 3.txt > file_master_echo $a .txt

最后,我希望输出文件名是:

file_master_5335672.txt

标签: bashshellcommand

解决方案


没有必要在echo那里使用(也必须指出它不是正确的使用方式)。此外,定义变量时不能留空格。也就是说,只需尝试:

a=5335672
cat 1.txt 2.txt 3.txt > file_master_$a.txt

推荐阅读