From owner-freebsd-questions@freebsd.org Fri Jun 21 23:40:41 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 0DAA815C3D5B for ; Fri, 21 Jun 2019 23:40:41 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EDF378788C for ; Fri, 21 Jun 2019 23:40:37 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([94.222.12.231]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPA (Nemesis) id 1MWiYi-1i6yLT44hU-00X7YK; Sat, 22 Jun 2019 01:40:28 +0200 Date: Sat, 22 Jun 2019 01:40:26 +0200 From: Polytropon To: Paul Schmehl Cc: FreeBSD Questions Subject: Re: How to un-select files in shell wildcard patterns Message-Id: <20190622014026.88ddb051.freebsd@edvax.de> In-Reply-To: <94FB6F4A679CD506CC02DCF2@Pauls-MacBook-Pro.local> References: <20190621054909.c6ba47ab.freebsd@edvax.de> <94FB6F4A679CD506CC02DCF2@Pauls-MacBook-Pro.local> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:4wpJqFjb/V/1DrxdFkOM55oXZSNXEXegQlXdBnKvhTp9o/RuXwv WnpL7z3izq/PiaWl7boU++TortduBOr1BCYuR7G3GggqRIrbFqGMi76itLfxC4qVFBP+vUd WFVwOiE3hdeFbMI081X+ep43GYqcdctE1cp2U4hNAwbqVDWiVcuUD9bTUtadKiIhLymOBi2 JpZLjZBpa6oPA7yyakTDQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:+6FXiqauMIQ=:SVLx7mWfvQUiHlS8Vswe9/ Bymv+kQHI+HtZwXMhvdJBmhk3XyHxki4v0ssxHkdiuh8M9021GCuTagiZHMDQcGBTzyqbxYff 4AKLWe8lHxxAz9LLNJn0AqMmSUfVfBmriph4l9DPuAHwzUa+jFvrxaLZPgET0QauYkdfB0FHV FTcHtShQLI6FSGlaqGvtBbwWbC/MeNqrdHdIxMeZi+MTJDEH14IY6GR3Ci7OGxCpKAtPX1S2A u7/311dvfBaTFjUuZVhWmEdffB3eee5pljO5oSv253HyCeuf2SwTSd0nijU5A6QXIeFL95Eei LzV3NlAw9rdVfTECo/pjO4tl9gPD84avPsLnAhSanYiECPrXsu9LuIRQx9O802DD4l3P/KsGx YV8/Hjj541DOrAqusbkcW590VfQDMoSFLP9IMcE3daM38AmCL0UVbSRvcDDm3dMgxTTqa+wZ4 j0Si3GAcKVprZNkIbwrIDMAiwM6zVrsy9HqSW5pIbL39p8+wPecY0leKJXwV3fXVjk4onVjP8 yTYTdz3qihee8AswCtQh3JBYFR1d5L30ljlHFikg1+EFJhvfcFGfNETxdsHBgZVyXhvUi0h33 GxaX5B9EVVMUD2IU6QsYsz198zuGgHAUCqUtQhAdNtjXgLDN06yJrMBSKs6OHWxU+IHapZVbY s+4zRjc+snqZw8GtJKMKzmDDK0kB13jNBFldCs+61UV8m3oaDxghfTDR7SRuMfBTsliJguJFa h/CJH8/PM7i678RwFNS0CO3Ezg94npHCJbDQgb5mIPB9ulYh79IMeovBO2w= X-Rspamd-Queue-Id: EDF378788C X-Spamd-Bar: +++++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [5.74 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: mx01.schlund.de]; RCPT_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_PBL(0.00)[231.12.222.94.zen.spamhaus.org : 127.0.0.11]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.87)[0.867,0]; MIME_GOOD(-0.10)[text/plain]; R_DKIM_NA(0.00)[]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.99)[0.994,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(1.00)[1.000,0]; RCVD_IN_DNSWL_NONE(0.00)[187.126.227.212.list.dnswl.org : 127.0.5.0]; MID_CONTAINS_FROM(1.00)[]; R_SPF_NA(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[187.126.227.212.rep.mailspike.net : 127.0.0.17]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.49)[ip: (1.39), ipnet: 212.227.0.0/16(-1.41), asn: 8560(2.50), country: DE(-0.01)] 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 23:40:41 -0000 On Fri, 21 Jun 2019 10:44:56 -0500, Paul Schmehl wrote: > --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. This is exactly what I an trying to avoid, i. e., not depend on external programs, but instead use what the shell offers interally. Of course, even regular grep can be used: ls | grep -v "a" | xargs ... foo ... or foo `ls | grep -v "a"` ... could implement the "_not_ this pattern" mechanism (just as the use of "awk '!/a/" with the ls output, to generate a list of the matching files (here: those that do _not_ match a certain pattern). So, is it correct that there is no shell builtin mechanism for this kind of "negative selection"? -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...