合并csv文件时,awk参数过长 [英] Awk argument too long when merging csv files

查看:41
本文介绍了合并csv文件时,awk参数过长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个文件夹中有超过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参数过长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆