我打印所有变量及其值
echo "$val"
mapreduce.map.memory.mb,3584
mapreduce.map.java.opts,-Xmx2560m
mapreduce.reduce.memory.mb,3584
mapreduce.reduce.java.opts,-Xmx2560m
mapreduce.task.io.sort.mb,1280
如何在每行的开头附加单词 - type_config
所以输出如下
type_config,mapreduce.map.memory.mb,3584
type_config,mapreduce.map.java.opts,-Xmx2560m
type_config,mapreduce.reduce.memory.mb,3584
type_config,mapreduce.reduce.java.opts,-Xmx2560m
type_config,mapreduce.task.io.sort.mb,1280
答案1
$ echo "$val" | sed 's/^/type_config,/g'
输出:
type_config,mapreduce.map.memory.mb,3584
type_config,mapreduce.map.java.opts,-Xmx2560m
type_config,mapreduce.reduce.memory.mb,3584
type_config,mapreduce.reduce.java.opts,-Xmx2560m
type_config,mapreduce.task.io.sort.mb,1280