Issue
I want to make column respect quoted column entries in order to optimise space.
cat testfile
123 "file name with spaces" tail
51 "longfilenamehere with spaces" head
Monday "shortname" hands
Blue "very longfilename_______________here with spaces" feet
Version with "column" which only respects spaces as column separators, the width of each column being determined by the widest entry
cat testfile | column -t
123 "file name with spaces" tail
51 "longfilenamehere with spaces" head
Monday "shortname" hands
Blue "very longfilename_______________here with spaces" feet
Whereas what I want is
123 "file name with spaces" tail
51 "longfilenamehere with spaces" head
Monday "shortname" hands
Blue "very longfilename_______________here with spaces" feet
Solution
xargs
is capable of parsing quotes. It could take arguments and pass them to printf
to output nicely separated output that could be feed to column.
$ cat testfile | xargs printf '%s|"%s"|%s\n' | column -t -s'|'
123 "file name with spaces" tail
51 "longfilenamehere with spaces" head
Monday "shortname" hands
Blue "very longfilename_______________here with spaces" feet
Answered By - KamilCuk Answer Checked By - Timothy Miller (WPSolving Admin)