My script is currently doing two function and I want to add one more as pre the question.
echo -en "Enter the logmsg="
read logmsg
logmsg1=${logmsg%%|*};
logmsg_len2=$(echo ${logmsg} | awk '{print $2}');
logmsg_suffix="|";
Char()
{
#echo $logmsg1
echo $logmsg1 | tr ',' '\n' | awk '{if($0~/^D/||/^S/) {print $0" starts"} else {print " Please check your input(e.g. Start it with D or S)";exit;}}'
}
Pipe()
{
if [[ "${logmsg_len2}" != "${logmsg_suffix}" ]]; then
echo -e "error use | symbol"
exit 1;
else
echo "success"
fi
}
Char
Pipe
This is the complete string which I am using in the script to get the desired results
D0000,D12345,S1234,D12345 | KestrelPrdV2_0.build.177 - svn 141115 tag as V2.0.0.14
Now my script will cut the left part (left from | symbol)
D0000,D12345,S1234,D12345
Now my question is how to calculate the length of the each varibale and also it should not more than 6 i.e. -le 6.Number of variables can be increases or decreases upto infinity.
Please let me know if more information require.