[Top][All Lists]

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

detecting no arguments in $@

From: dora-solomon
Subject: detecting no arguments in $@
Date: Sun, 25 Jul 2021 13:16:07 +0200 (CEST)

From: Andreas Kusalananda Kähäri <>
Subject: Re: detecting no arguments in $@
Date: 25/07/2021 13:11:14 Europe/Paris

On Sun, Jul 25, 2021 at 01:07:53PM +0200, wrote:
> Is it possible to figure out whether there are no arguments in $@ ?

If there are no positional parameters, i.e. if "$@" is empty, then "$#"
would be zero:

if [ "$#" -eq 0 ]; then
echo 'there were no arguments given'

I was using shift  to get passed some options and if the last arguments did not

contain anymore information such as directory names, I would set defaults.

reply via email to

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