2

I've read this thread https://unix.stackexchange.com/a/7718/256195, that only if var doesn't contain any tab/spaces but in my case it does contain spaces, like below example:

"this is a test"      this_is_a_solid_line_that_doesnot_contain_tab_or_spaces

command column will separate this is ..etc also, but I'd want something acts on only "this is a test" and this_is_a_solid_line_that_doesnot_contain_tab_or_spaces.

Purpose: I have a bunch of lines like above in a file that don't be aligned properly.

Tuyen Pham
  • 1,805

1 Answers1

2

Assuming the input doesn't contain | characters, you could convert those sequences of whitespace that are not inside quotes to | (or any other character that doesn't occur in the input) and then pipe to column -ts'|':

<input.txt perl -lpe 's/(".*?")|\s+/$1||"|"/ge' | column -ts'|'