I coded the following to display data formatted in columns:
str1='hello i am robert
and your ma frnd'
str2='thisisaverylongword thisistoohehehe andherefinishthe string
hereis a other linefortheexample'
IFS=$'\n'
echo '----------------------'
echo 'STRING SHORT'
echo '----------------------'
echo "$str1" | column -t
echo
echo '----------------------'
echo 'STRING LONG'
echo '----------------------'
echo "$str2" | column -t
Which outputs:
----------------------
STRING SHORT
----------------------
hello i am robert
and your ma frnd
----------------------
STRING LONG
----------------------
thisisaverylongword thisistoohehehe andherefinishthe string
hereis a other linefortheexample
Ok, now I'm trying to format the string with the same pattern, but without merge them.
This is the result I'm looking for:
----------------------
STRING SHORT
----------------------
hello i am robert
and your ma frnd
----------------------
STRING LONG
----------------------
thisisaverylongword thisistoohehehe andherefinishthe string
hereis a other linefortheexample
Do you have any idea to do it? May be merging the strings and splitting it before the format?
Note that this is only an example, I'm looking for a generic solution, not only for this specific case.
