1

I'm using grep, sed and column to make a little makefile documentation, but I get the following error: column: line too long.

My attempt is the following:

## this is the documentation
yes:
  @echo hello

help:
  @grep -Pzo "##.*\n[a-zA-Z0-9_-]+:" $(MAKEFILE_LIST) \
  | sed -z "s/\n/,/"                                  \
  | sed -n "s/##\(.*\),\(.*\)[:, 1]/\2\1/p"           \
  | column -t -s ','

I really don't understand the problem here because when I run the command without the column I get a line size way below the 2049 (defined by MAXLINELEN in C code).

Answer

After reading the answer I concluded that I just needed to add a '\n' to the end of my second grep. Like this:

sed -n "s/##\(.*\),\(.*\)[:, 1]/\2\1\n/p"

1 Answer 1

2

It's likely because you are passing it a non newline-terminated string:

$ printf 'foo,bar,baz\n' | column -t -s,
foo  bar  baz

but

$ printf 'foo,bar,baz' | column -t -s,
column: line too long

Perhaps consider replacing sed -z "s/\n/,/" in your pipeline with paste -sd,

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .