You could try this for a input-file called input
:
csplit -f tempfile input '/-/+1' '{*}'; paste tempfile*
With csplit
we generate one file for each “column” in the desired output (tempfile01
, tempfile02
, …).
Next, we merge these temporary files. With the given sample input, the output of the above command is:
jim sally bill jerry
bob sue - curly
- ed phil
- -
It might be a good idea to add rm tempfile*
to do the necessary cleanup.
csplit -f tempfile input '/-/+1' '{*}'; paste tempfile* > output; rm tempfile*
1
solved How to move everything following a dash to a new column?