Evening all,
I am having a little fun with some shell scripting but I am stuck creating a loop. Hopefully someone can help. Here is my script:
As you can see if $FORTUNE is less than 140 characters it will echo the text and then close. If $FORTUNE is greater than 140 it will just close. What I want it to do is if its greater than 140 to re-run again until its less than 140, echo and then exit.
Hope this makes sense?
I am having a little fun with some shell scripting but I am stuck creating a loop. Hopefully someone can help. Here is my script:
Code:
#!/bin/bash
FORTUNE=`fortune -i`
COUNT=`echo $FORTUNE | wc -m`
if [ $COUNT -lt 140 ]
then
while true; do
echo "$FORTUNE" && exit
done
fi
As you can see if $FORTUNE is less than 140 characters it will echo the text and then close. If $FORTUNE is greater than 140 it will just close. What I want it to do is if its greater than 140 to re-run again until its less than 140, echo and then exit.
Hope this makes sense?