使用列命令的 Bash 错误:“列:行太长" [英] Bash error using the column command: 'column: line too long'
本文介绍了使用列命令的 Bash 错误:“列:行太长"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在输入文件中输入此列命令时,出现以下错误
When I type this column command with my input file I get the following error
column -t text.txt > output
column: line too long
column: line too long
column: line too long
column: line too long
column: line too long
column: line too long
当我查看文件输出时,似乎没有打印文件的前半部分(从左到右).
When I look at the file output it seems that the first half of the file(from left to right) is not printed.
有没有办法解决这个错误?有没有办法在没有这个错误的情况下完全按照命令执行的操作?
Is there a way around this error? Is there a way to do exactly what the command would do otherwise without this error?
样本输入(真实输入 ~640 列)
Sample input (Real input ~640 columns)
column1 column2 column3 column4
03 2 45 3
5 6 7 8
样本输出(实际输出 ~640 列)
Sample output (Real output ~640 columns)
column1 column2 column3 column4
03 2 45 3
5 6 7 8
推荐答案
你可以尝试一个简单的 awk 实现:
You could try a naive awk implementation:
awk 'NR==FNR{for(i=1;i<=NF;i++)
max[i] = length($i) > max[i] ? length($i) : max[i]; next}
{ for(i=1;i<=NF;i++) printf "%-"max[i]"s ", $i; printf "\n"}' text.txt text.txt
这篇关于使用列命令的 Bash 错误:“列:行太长"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文