小编Iva*_*kov的帖子

运行时命令每个输出的前缀

我正在尝试制作一个模块化脚本。我有几个从单个脚本调用的脚本/命令。
我想为每个单独命令的输出添加前缀。

例子:

我的文件都是commands.sh/command1.sh/command2.sh

command1.sh输出
file exists
file moved

command2.sh输出
file copied
file emptied

allcommands.sh运行脚本command1.sh和command2.sh

我想为这两个脚本的每个输出添加前缀,如下所示:
[command1] file exists
[command1] file moved
[command2] file copied
[command2] file emptied

linux bash shell command-line bash-scripting

16
推荐指数
2
解决办法
1万
查看次数

标签 统计

bash ×1

bash-scripting ×1

command-line ×1

linux ×1

shell ×1