Hi I have a csv file with below entries
11
22
13
,,
aa
bb
cc
,,
ww
kk
ll
,,
Please suggest me a linux command or script which can split this colomun into 3 columns in the same file like below
11 aa ww
22 bb kk
13 cc ll
Hi I have a csv file with below entries
11
22
13
,,
aa
bb
cc
,,
ww
kk
ll
,,
Please suggest me a linux command or script which can split this colomun into 3 columns in the same file like below
11 aa ww
22 bb kk
13 cc ll
Here's a nice crazy shell pipeline that actually does what the OP wants :!
Then
I'm sure there's better commands without resorting to code.
EDIT Thanks to @user000001 for the heads-up on my error making me revisit my solution.
with awk
Output
You can do it with
awk
.Create a file named
script.awk
, with the following contents:Run file like this:
Output:
Or if you just want a one-liner, do this:
EDIT:
This will add commas between the fields:
Tested below:
This might work for you: