help-bash
[Top][All Lists]
Advanced

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

Re: Deleting files


From: Chris Elvidge
Subject: Re: Deleting files
Date: Mon, 22 Feb 2021 11:05:18 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Lightning/5.4

On 22/02/2021 06:39 am, michael-franzese@gmx.com wrote:
How can I write the following compactly

if (( nargs > 2 )); then
     if [[ "${3}" == "t" ]]; then
        remove_file=true
     fi
fi

Here, you don't really need to check number of arguments. If $3 is not given, it will be unset, so:

[ "$3" = "t" ] && remove_file=true

will do it.
Should you check for "T" as well?

--
Chris Elvidge
England




reply via email to

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