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 14:15:24 +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 12:31 pm, michael-franzese@gmx.com wrote:





Sent: Monday, February 22, 2021 at 11:05 PM
From: "Chris Elvidge" <celvidge001@gmail.com>
To: help-bash@gnu.org
Subject: Re: Deleting files

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?

I could do with that as well.

--
Chris Elvidge
England





[ "$3" ] && N="${3^}" && [ "$N" = "T" ] && remove_file=true


--

Chris Elvidge

5 Ebor Park, Appleton Roebuck, York.  YO23 7DZ.
Tel (Mob): +447443472958 mailto:celvidge@outlook.com

Calle Padre Raimundo Codesal 1, Vélez-Málaga, 29700, España





reply via email to

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