bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test for "command not found" before expanding shell parameters


From: Alan Young
Subject: Re: test for "command not found" before expanding shell parameters
Date: Sun, 20 Apr 2014 11:58:21 -0600

greo=$(command -v greo)

if [ -n $greo ]; then
  $greo ...
fi

command will search the directories defined in $PATH for the command
greo and return the fully qualified path.  If it isn't found it will
return null.  So, if $greo is non-zero, greo exists and you can run
it.

On Sun, Apr 20, 2014 at 11:52 AM, Toralf Förster <toralf.foerster@gmx.de> wrote:
> Under Gentoo Linux I'd like to grep for various things in the package 
> database in the following way:
>
> $> greo semanti /var/db/pkg/*/*/USE
>
> This might take a longer time for a low device before I'm faced with the 
> message:
>
> "bash: greo: command not found"
>
> /me wonders if it is mandatory first to expand the complete command line 
> before realizing that the command isnÄt ther ?
>
> --
> Toralf
>
>



-- 
Alan Young



reply via email to

[Prev in Thread] Current Thread [Next in Thread]