Im new in bash and dont have much idea in programming (2 weeks experience), the thing is:
I have to make a script that obtains the information from columns and classify them, that is already resolved with something like this:
command | head -n +(whatever) | awk -F[whatever] '{print $1 ...}'> text.txt #awk only if needed
cat text.txt | (while read variable[1-...]
do
var=value
if [[condition]]; then
echo "message"
fi
)
The info is obtained from tables with this formats:
------------
|title|title| title title
+-----+-----+ or
|info |info | info info
-------------
The problem comes when one column has instead of one word, multiple:
title | title
info | the info
I need to obtain the whole string, and with the method Im using Im pretty sure its impossible, but I dont know what to do and cant seem to fin the same problem anywhere
I cant place field separators manually because the info could change and it would mess the entire output.
Edit:
The command could be, for example:
lmctl get (options)
and the output:
NAME AGE INSTANCES READY STATUS PRIMARY
(name) 119d 3 3 Cluster in healthy state (primary)
Here I would need to obtain "Cluster in healthy state", but dont know how
Im working on a server with redhat openstack 16, for this script, Im using openshift commands to get info from pods or stuff like that, i believe its autogenerated by the command, so I just would need to obtain the info from its output
Edit2:
The expected output (when failing) from my script would be:
[ERROR] [NAME] $VARIABLE1 [STATUS] $VARIABLE2
when OK:
$VARIABLE1(name): [OK]; Status: $VARIABLE2(status)
Here is the problem, with the actual script, the status outut would be "Cluster", only