From owner-freebsd-questions Sun Apr 12 20:13:25 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA20046 for freebsd-questions-outgoing; Sun, 12 Apr 1998 20:13:25 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from dan.emsphone.com (dan@dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id UAA20038 for ; Sun, 12 Apr 1998 20:13:19 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.8.8/8.8.6) id WAA10755; Sun, 12 Apr 1998 22:13:18 -0500 (CDT) Message-ID: <19980412221317.A10661@emsphone.com> Date: Sun, 12 Apr 1998 22:13:17 -0500 From: Dan Nelson To: Dean Hollister , FreeBSD Questions Subject: Re: bash: checking for empty string? References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.90.10i In-Reply-To: ; from "Dean Hollister" on Mon Apr 13 10:50:47 GMT 1998 X-OS: FreeBSD 2.2.6-STABLE Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In the last episode (Apr 13), Dean Hollister said: > Hiyall, > > If have a string $name. I need to check if this is blank, and if it > is, exit the script. Any ideas? These will work with any bourne-shell based script; not just bash. [ -z "$name" ] && exit [ "$name" = "" ] && exit if [ -z "$name" ] then exit fi Note that $name will expand to "" if $name is unset or is set to the empty string. To learn how to tell the difference, man sh and search for "parameter expansion". -Dan "You can rule the world with /bin/sh" Nelson dnelson@emsphone.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message