我试图从一个较大的csv文件中提取相关信息以进行进一步处理,因此我想将列名(标题)保存在我的输出mini-csv文件中。
我有:
grep "Example" $fixed_file | cut -d ',' -f 4,6 > $outputpath"Example.csv"
在生成具有两列的csv文件时效果很好,但是我希望标头信息也包含在输出文件中。
使用命令分组并添加head -1
到混合中:
{ head -1 "$fixed_file" && grep "Example" "$fixed_file" | cut -d ',' -f 4,6 ;} \
>"$outputpath"Example.csv
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句