Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion What effect does "shopt -s extglob" has on "find" command in bash ?

Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 01 Feb 2008 15:57:01 -0600
From: "Dan Mercer" <damer...@comcast.net>
Newsgroups: comp.unix.shell
References: <47e375f8-8f5f-4003-8ca6-c6c1c97797f7@s37g2000prg.googlegroups.com>
Subject: Re: What effect does "shopt -s extglob" has on "find" command in bash ?
Date: Fri, 1 Feb 2008 15:57:00 -0600
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
Message-ID: <77ydnRe446kwCD7anZ2dnUVZ_v2pnZ2d@comcast.com>
Lines: 46
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 76.17.175.203
X-Trace: sv3-iqJM2qicCu5lRK7UBfvIrfEyb0OYjak/MM3HY5jA/UlYIv9HcxY1c1cWv6YqBo/1ES6GYB56lY2KDK5!tYkbyLbD1gDkQJyGx0VaVzIfbFtL9fJg9UkGRowgxTFNgXe34hTkeBXYuvXU0WEgKSFo8DT3V3OK!qhLfvkGHRGwVhYeM8T4LlvXOzb/1cg==
X-Complaints-To: abuse@comcast.net
X-DMCA-Complaints-To: d...@comcast.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.37


"Eric" <rc.ch...@gmail.com> wrote in message news:47e375f8-8f5f-4003-8ca6-c6c1c97797f7@s37g2000prg.googlegroups.com...
: I have turned on extglob in bash, but it behaves very strange when I
: use find command. Please see:
:
: shsvr:/home/tom/tmp/test1$ echo $SHELL
: /bin/bash
: shsvr:/home/tom/tmp/test1$ shopt -s extglob
: shsvr:/home/tom/tmp/test1$ ls *
: -rw-r--r--    1 tom     msc             0 Feb  1 15:47 File1.java
: -rw-r--r--    1 tom     msc             0 Feb  1 15:47 File2.java
: -rw-r--r--    1 tom     msc             0 Feb  1 15:47 Makefile
:
: SCCS:
: total 0
: -rw-r--r--    1 tom     msc             0 Feb  1 15:47 s.File1.java
: -rw-r--r--    1 tom     msc             0 Feb  1 15:47 s.Makefile
: -rw-r--r--    1 tom     msc             0 Feb  1 15:47 s.File2.java
:
: shsvr:/home/tom/tmp/test1$ find .  -name !(s.*.java)

This expanded to find .  -name File1.java File2.java Makefile SCCS

-name doesn't support extended globbing and the patterns should be quoted
to avoid unintended expansion by the shell.  What you really want is:

   find . ! -name 's.*.java'

Dan Mercer

: find: paths must precede expression
: Usage: find [path...] [expression]
:
: shsvr:/home/tom/tmp/test1$ find SCCS -name !(s.*.java)
: find: paths must precede expression
: Usage: find [path...] [expression]
:
: shsvr:/home/tom/tmp/test1$ cd SCCS
: shsvr:/home/tom/tmp/test1/SCCS$ find .  -name !(s.*.java)
: ./s.Makefile
:
: What should I do to make find works properly ?
:
: Thanks in advance.