From owner-freebsd-questions@freebsd.org Fri Jun 21 15:45:05 2019 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F4A315B442A for ; Fri, 21 Jun 2019 15:45:05 +0000 (UTC) (envelope-from pschmehl_lists@tx.rr.com) Received: from dnvrco-cmomta01.email.rr.com (dnvrco-outbound-snat.email.rr.com [107.14.73.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id AA7FF6DDEF for ; Fri, 21 Jun 2019 15:45:02 +0000 (UTC) (envelope-from pschmehl_lists@tx.rr.com) Received: from [192.168.0.7] ([70.121.63.82]) by cmsmtp with ESMTPA id eLiihuA8zP088eLimh5KBy; Fri, 21 Jun 2019 15:45:01 +0000 Date: Fri, 21 Jun 2019 10:44:56 -0500 From: Paul Schmehl Reply-To: Paul Schmehl To: Polytropon , FreeBSD Questions Subject: Re: How to un-select files in shell wildcard patterns Message-ID: <94FB6F4A679CD506CC02DCF2@Pauls-MacBook-Pro.local> In-Reply-To: <20190621054909.c6ba47ab.freebsd@edvax.de> References: <20190621054909.c6ba47ab.freebsd@edvax.de> X-Mailer: Mulberry/4.0.8 (Mac OS X) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-CMAE-Envelope: MS4wfJdn68kw9qk2LS746JYiWc4xgekcRogEpgES2UzBj16JxXFJNV8yEdpIxiPZYnnB4YyAOIR7Kwl9OMwCUrUa1JB3ANqSlC1CSvDmt4DqyAOtLAUdA81C rfQLTNzbSZKRrX4w0qnN35WDdHGO9zTUdi2URVtbAL7yn4i949JXvmHkvH2+SmKloLjs5Xy+lz5iezdW+MYnQQZV0EPXDjHrq8+S44+VYrypSgzUdvOki1q9 X-Rspamd-Queue-Id: AA7FF6DDEF X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of pschmehl_lists@tx.rr.com designates 107.14.73.225 as permitted sender) smtp.mailfrom=pschmehl_lists@tx.rr.com X-Spamd-Result: default: False [-4.49 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[pschmehl_lists@tx.rr.com]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:107.14.73.0/24]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[rr.com]; REPLYTO_EQ_FROM(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[dnvrco-cmedge01.email.rr.com,dnvrco-cmedge02.email.rr.com]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[225.73.14.107.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_SHORT(-0.85)[-0.847,0]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; IP_SCORE(-1.33)[ipnet: 107.14.73.0/24(-3.68), asn: 7843(-2.94), country: US(-0.06)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:7843, ipnet:107.14.73.0/24, country:US]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jun 2019 15:45:05 -0000 --On June 21, 2019 at 5:49:09 AM +0200 Polytropon wrote: > I'm interested in a convenient method to "un-select" files > when using regular (sh) shell wildcards. It's quite easy to > describe things like > > *.tex > > to perform an operation on all LaTeX source files, or > > *a* > > on all files whose name contains (at least) one "a". Patterns > that are based on the inclusion of certain attributes are not > a problem to deal with using the builtin pattern matching of > the shell. > > But what about the opposite? Let's say, perform an operation > on all files _except_ the LaTeX source files, or all files > whose name does _not_ contain an "a"? > > Is there a good method to do this, except creating a kind > of "custom regex wrapper script" that does the selection part, > for further use with `subshell` or | xargs? I feel almost silly trying to suggest anything to *you*, but egrep '(foo|bar|zed|fam). does the trick. So, for example, if you want to do something in the shell to act on all files except ones that end in .tex or have an a in their name: ls -al| egrep '(a|\.tex)' * | awk (whatever), etc. Paul Schmehl, Retired My opinions are my own. ******************************************* "It is as useless to argue with those who have renounced the use of reason as to administer medication to the dead." Thomas Jefferson "There are some ideas so wrong that only a very intelligent person could believe in them." George Orwell