At 05:29 PM 6/22/2005, Chris F.A. Johnson wrote:
On 2005-06-22, [EMAIL PROTECTED] wrote:
> Hello,
>
> I have an if statement, something like:
>
> if [ "$day" = "Thu" ]; then
> tar -cpf /var/backups/homethu.tar /home
> fi
>
> If I decide to pound out the tar command, then the script
> will error and it won't continue on.
> Is it possible to pound out the tar command and still leave the if
> statement intact? even though there is no command to do.
if [ "$day" = "Thu" ]; then
: tar -cpf /var/backups/homethu.tar /home
fi
I like this answer the best. (So does my favorite book, "Unix Power
Tools.") The colon executes a command that doesn't do anything, so the
loop is happy. And the original tar syntax is left there for you to see
for later. The only drawback is if you overlook the colon in future
debugging. You could always throw in a # as well (after the colon) if
you're worried about that, your eye will catch # a lot easier than :
-Andy
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]