On 11/12/2015 08:41 AM, Michael Convey wrote: > I'm trying to find the following files with a single 'find' statement: > > /var/lib/postgresql/9.4/main/postgresql.auto.conf > /usr/lib/tmpfiles.d/postgresql.conf > /etc/postgresql/9.4/main/postgresql.conf > > I tried the following (and more), but I can't figure it out: > > find / -iregex "*postgresql.*.conf"
This says find all files that match the case-insensitive regular expression "*postgresql.*.conf". A regex of ".*." is identical to a regex of ".+" (1 or more arbitrary characters), and NOT the same as a regular expression for a literal '.'. A leading "*" in a regular expression is unspecified behavior, but many regex engines treat it identically to a regex of "\*" (matching only a literal '*'). As your desired filenames do not start with a literal star, the regex won't match them. > find / -iregex "*/postgresql*.conf" Still a literal star issue. > find / -iregex *postgresql*.conf Here, you lack shell quoting, so your shell tries to glob the '*' before even passing the argument to find. Generally not what you want. > find / -iregex '*postgresql.*.conf' This is no different than your first attempt (changing between '' and "" shell quoting doesn't affect the string seen by find). What you probably want is to use '-iname', not '-regex', for a case-insensitive glob comparison. As in: find / -iname 'postgresql.*conf' -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature