3
1
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?
It’s the tab character – Tony Stewart Sunnyskyguy EE75 – 2018-06-26T21:55:37.753
If
\tdoesn't do it, maybe^twill? – cybernetic.nomad – 2018-06-26T21:56:45.2871
tris 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. – creidhne – 2018-06-27T00:29:44.453@creidhne funny thing is when I asked the best way to replace a substring with another string before people said to not use
sedand usetr....sedis quite confusing for me and for a simple replace without any regex it's not anymore helpful. – user14492 – 2018-06-28T13:11:09.4401But did the
sedcommand solve the problem? The problem withtris that it translates characters, not strings.seduses so-called "basic regex" butsed -Euses modern "extended regex". Thesedcommand replaces every,(comma followed by a blank) with a tab character. Would an answer help? – creidhne – 2018-06-28T13:49:03.410"for a simple replace without any regex ".. || reminds me.. in Japanese technologies... The toughest/advanced one to handle, is the simple one. (simplest solution/zero-thinking-on user site) || If the method works.. then it ok.. If not, we always have the option to create our own program and/or using assembly/c++ . || I hope you don't get me wrong.. I'm just interested to know if it works.. + I don't have a mac to try it out. [ : – p._phidot_ – 2018-10-11T19:33:28.500
You are using command line utility (as I understand by seeing >) and sed and tr, why you tagged this post "microsoft-excel microsoft-word worksheet-function"? I mean are you doing these changes in .doc(x), .xls(x) files? You surely can't as they are proprietary format and can't be edited from command line as above. And where does worksheet function fit here? – VSRawat – 2019-02-08T17:56:24.337
@VSRawat who are you, the tag police? What is the purpose of that comment? One can argue you’re spamming and not adding anything of value to the question. – user14492 – 2019-02-08T18:02:09.713
All I am saying that if those tags are not relevant for the content of this post, you should remove that and put only such tags as are required for this post. If you think I am spamming, no issue, please flag my comment so that some moderator reads and judges it. – VSRawat – 2019-02-08T18:08:43.507