考虑我在Unix下有一个UNIX文件夹我有一个XYZ.csv
"id","name","salary"--- Header
"1","Jon","1000"---line
输出应该是
"UNIX1","Jon","1000"
答案 0 :(得分:0)
见下面的例子:
kent$ pwd
/tmp/test/UNIX
kent$ head f
"id","name","salary"--- Header
"1","Jon","1000"---line
kent$ awk -v p="$(basename $PWD)" 'NR==2{sub(/"/,"&"p)}1' f
"id","name","salary"--- Header
"UNIX1","Jon","1000"---line
如果它不是您想要的,请在您的问题中添加要求,而不是将其放在评论中。