问题描述
我在一个文件夹中有超过10000个csv文件,我正在尝试使用awk逐行合并它们,但是如果我运行以下命令: printf'%s \ n'* .csv |xargs猫|awk'FNR == 1&&NR!= 1 {next;} {print}'* .csv>master.csv
我收到以下错误:
/usr/bin/awk:参数列表太长和 printf:写入错误:管道损坏
I have more than 10000 csv files in a folder and I'm trying to merge them by line using awk but if I run this command:printf '%s\n' *.csv | xargs cat | awk 'FNR==1 && NR!=1{next;}{print}' *.csv > master.csv
I get the following errors:
/usr/bin/awk: Argument list too long and printf: write error: Broken pipe
推荐答案
使用 printf
和 xargs
部分,您将发送内容将csv文件转换为awk,但您也将文件名提供给awk.选择一个或另一个:我建议:
With the printf
and xargs
parts, you are sending the contents of the csv files into awk, but you also provide the filenames to awk. Pick one or the other: I'd suggest:
{ printf '%s\n' *.csv | xargs awk 'FNR==1 && NR!=1{next;}{print}'; } > master.csv
这篇关于合并csv文件时,awk参数过长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!