Pivot example

Hi all, I am new to shell scripting so pardon me for the questions I will be asking.

I was given a task where I have to pivot my data

Example
Source

SGPAPCTUMACCHEA

Expected output

SGP APC TUM
SGP APC ACC
SGP APC HEA

Can anybody assist me on this?

Welcome to the forum.

Please become accustomed to provide decent context info of your problem.

It is always helpful to carefully and detailedly phrase a request, and to support it with system info like OS and shell, related environment (variables, directory structures, options), preferred tools, adequate (representative) sample input and desired output data and the logics connecting the two including your own attempts at a solution, and, if existent, system (error) messages verbatim, to avoid ambiguities and keep people from guessing.

A guess from staring at your samples: you want the input to be grouped by three chars, and then reassemble those groups into a new pattern, repeating the first group. Is that input in a file, a variable, read from stdin, ...?

Final remark:
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

Hi,
Maybe it will brighten the silence?
For instance bash 4.4 linux

sed -nr '
s/(.{9})(.*)/\1~\2  /;h
b2
:1
s/(.*)(.{3})~(.{3})(.*)/\1\3~\4/
:2
h;T
s/(.{3})(.{3}).*(.{3})~.*/\1 \2 \3/p
g
t1' <<<"SGPAPCTUMACCHEA"

a shell ex.:

string=SGPAPCTUMACCHEA
c=3

for (( i=(( c * 2 )); i<${#string}; i+=c ))
do
   echo "${string:0:c} ${string:c:c} ${string:i:c}"
done