Bash error using command column: 'column: line too long'

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 output of the file, it appears that the first half of the file (from left to right) is not printed.

Is there a way to get around this error? Is there a way to do exactly what the team would have done otherwise without this error?


Input example (real input ~ 640 columns)

column1 column2 column3 column4
03  2   45  3
5   6   7   8

      

Sample output (real output ~ 640 columns)

column1    column2  column3  column4
03         2        45       3
5          6        7        8

      

+5


source to share


2 answers


You can 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

      

+5


source


An alternative is to split the string into an array. This line is too long column

to print out completely:

FULLTEXT=$(cat /Users/burroughclarke/Desktop/commaseperatedvalues.csv)
printf "$FULLTEXT" | column  -t -s ','

      



This prints correctly:

readarray -t ARR < <(cat /Users/burroughclarke/Desktop/commaseperatedvalues.csv | tr "\n" "\n") 
printf '%s\n' "${ARR[@]}" | column  -t -s ','

      

+1


source







All Articles