You know when you copy a row from a table and paste it into another one it is in the correct place. So what is the character that is between cell values when this operation is performed.
Eg. I have this text: Phone (P), Email (E), Home (H)
and if I replace all the ,
with \n
and paste the text in a tabular formant in Pages/Word/Excel, it is interpreted as a column.
To replace the string with new line I used:
> pbpaste | tr -s ', ' '\n' | pbcopy
I tried \t
, and \n\n
but they're still pasted as a row.
Next I tried copying it in a row and printing on the terminal using (gcat
because I'm on macOS):
> pbpaste | gcat -A
a^Ib^Ic⏎
Reading the docs it says:
display TAB characters as ^I
But replacing ,
with \t
doesn't do it. Does anyone know what character this is and how I can replace a comma with it to paste a row?
\t
doesn't do it, maybe^t
will?tr
is the wrong command for this task. Trypbpaste | sed 's/, / /g' | pbcopy
. Note that you can't simply copy the command from this comment. Control-v followed by the tab key allows you to enter a tab character on the Terminal command line. When typing this command in Terminal, types/, /control-v tab/g
.sed
and usetr
....sed
is quite confusing for me and for a simple replace without any regex it's not anymore helpful.sed
command solve the problem? The problem withtr
is that it translates characters, not strings.sed
uses so-called "basic regex" butsed -E
uses modern "extended regex". Thesed
command replaces every,
(comma followed by a blank) with a tab character. Would an answer help?