bug-bash
[Top][All Lists]
Advanced

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

Re: extension of file-test primitives?


From: Chet Ramey
Subject: Re: extension of file-test primitives?
Date: Mon, 21 Aug 2017 16:11:03 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 8/21/17 9:27 AM, Greg Wooledge wrote:
> On Sat, Aug 19, 2017 at 05:30:34PM -0700, L A Walsh wrote:

>> Allowing:
>>
>>   test -{f,x} /bin/ls && ...
>> or
>>    if [[ -{f,x} $file ]]; then ... ; fi
>>
>> instead of:
>>
>>   test -f /bin/ls && test -x /bin/ls && ...
> 
> You could write your own helper functions for this:
> 
> -fx() { test -f "$1" && test -x "$1"; }

This is indeed a quick and easy way to implement desired functionality.
Shell functions can do a lot.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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