bugfindutils - Bugs: bug #44570, Wrong find -type f -not -name...

 
 

bug #44570: Wrong find -type f -not -name "*txt" result for files with weird names

Submitter:  Jan Kocoń <kotu88>
Submitted:  Wed 18 Mar 2015 02:29:04 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Working as Intended
Privacy:  Public Assigned to:  ericb
Originator Name:  Open/Closed:  Closed
Release:  4.4.2 Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 18 Mar 2015 04:17:08 PM UTC, comment #2: 

Yes, LC_ALL=C solved this problem. It is not a bug in 'find'. Thank you!

Jan Kocoń <kotu88>
Wed 18 Mar 2015 03:08:00 PM UTC, comment #1: 

Try again, using: LC_ALL=C find -type f -not -name '*.txt'

My guess is that you are in a non-C multibyte locale, and that the filenames being printed are ones that are invalid when interpreted in the multibyte encoding rules of your current locale.  globbing is only required to work on valid encoded content, so the fact that you have a name that is not a valid encoding means that the glob cannot match it, and therefore it gets printed even though it ends in a .txt ending.  Switching to a locale where there are no encoding errors (such as LC_ALL=C) will avoid the problem.

Oh, and don't use: -name .txt.  You WANT to use -name '.txt' (so that the shell is not expanding the glob prior to calling find, but rather that find is being given a literal glob to expand itself).

Eric Blake <ericb>
Group administrator
Wed 18 Mar 2015 02:29:04 PM UTC, original submission:  

When I type
find -type f -not -name "*txt"
or even:
find -type f -not -name *txt
on my data, there is a problem with some files (I attached a small subset of that data). There is a result below:
kotu@..../tmp$ find -type f -not -name *.txt
./http___medjugorje_hr_/ا?%84?%86د?%88ة-ا?%84د?%88?%84?%8Aة-ا?%84أ?%88?%84?%89-?%84?%84أطباء-?%88ا?%84?%85?%85رضات-?%88ا?%84عا?%85?%84?%8A?%86-?%81?%8A-?%85جا?%84-ا?%84طب-?%81?%8A-?%85د?%8A?%88غ?%88ر?%8A?%87,4785.html.plain.txt
./http___www_abacosun_com_pl_/1085,?%93?%98?%90?%9BУР?%9E?%9D?%9E?%92?%90Я_?%9A?%98С?%9B?%9EТ?%90_наполнение_мо?%80?%89ин_и_?%81кладок_ко?%80?%80ек?%86и?%8F_?%84о?%80м?%8B_г?%83б.plain.txt
./http___lancuchy_net_/kolko-do-kluczy-10-xl.htm?st=?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%82a?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%84cuch ogniwo ?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%9Br.plain.txt
./http___lancuchy_net_/kolko-do-lancucha-10x60w-irma.htm?st=?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%82a?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%84cuch ogniwo ?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%9Br.plain.txt
./http___lancuchy_net_/lancuch-niezgrzewany-12mm-bialy.htm?st=?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%82a?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%84cuch ogniwo ?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%9Br.plain.txt
./http___www_bgk_com_pl_/?%9A?%80еди?%82?%8B-о?%82-?%95в?%80опей?%81кого-инве?%81?%82и?%86ионного-банка-дл?%8F-?%84инан?%81и?%80овани?%8F-?%80егионал?%8Cного-?%80азви?%82и?%8F-ru.plain.txt
./http___instar_net_pl_/Те?%80ка-дл?%8F-?%87и?%89енн?%8F-?%96-пол?%96?%80?%83ванн?%8F-ке?%80ам?%96?%87ни?%85-пли?%82ок-?%96-ви?%80?%96вн?%8Eванн?%8F-епок?%81идни?%85-?%88в?%96в.plain.txt
./http___www_bonuseurotech_com_pl_/?%9B?????%82?%8B-?????%8F-????????????????-?????%88??????-??-???????????%80?%82????,29.html?&bViewAll=true&bViewAll=true&bViewAll=true&bViewAll=true&bViewAll=true&bViewAll=true&bViewAll=true&bViewAll=true.plain.txt

These files shouldn't be in output, am I right?

Jan Kocoń <kotu88>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #33389:  tmp.7z added by kotu88 (269KiB - application/x-7z-compressed)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jay (Updated the item)
  • -email is unavailable- added by ericb (Posted a comment)
  • -email is unavailable- added by kotu88 (Submitted the item)
  • -email is unavailable- added by kotu88
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-09-01 jay StatusNone Working as Intended
        Assigned toNone ericb
        Open/ClosedOpen Closed
    2015-03-18 kotu88 Attached File- Added tmp.7z, #33389
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code