From: jellybean stonerfish on
On Mon, 22 Feb 2010 02:15:08 +0000, David Combs wrote:

>>Usual caveat about file names that contain newlines.
> That is a joke, yes? Although I wouldn't put it past Windows to
> allow it!

I don't know about windows, but I do now that newlines are valid
characters on linux with ext3. As are tab and backspace.

Using rename gives me an error with \n, but it still works,
as you can see below.

# notice the x, y, and z in the filename
$ touch xstrangeyfilezname
$ ls *strange*
xstrangeyfilezname
# replace x with a tab
$ rename 's/x/\t/' *strange*
# replace y with newline and tab
$ rename 's/y/\n\t/' *strange*
Unsuccessful stat on filename containing newline
at /usr/bin/rename line 59.
# replace z with newline, tab, and backspace
$ rename 's/z/\n\t\b/' *strange*
Unsuccessful stat on filename containing newline
at /usr/bin/rename line 59.
# ls shows the strange characters as question marks
$ ls
?strange??file???name
# echo treats them as what they are
$ echo *
strange
file
name


From: Jon LaBadie on
David Combs wrote:
> In article <slrnhmuiu8.2v8.usenet-nospam(a)guild.seebs.net>,
> Seebs <usenet-nospam(a)seebs.net> wrote:
>> On 2010-02-07, laredotornado <laredotornado(a)zipmail.com> wrote:
>>> How would I search for files that have the same name, but potentially
>>> different case, living in the same directory? For example, I would
>>> want to find files like
>> Within a directory:
>>
>> for file in *
>> do
>> if ls | grep -v "^$file\$" | grep -qi "^$file\$"
>> then echo "found similar matches for '$file'."
>> fi
>> done
>>
>
> Good Lord, that's O(n^2), right off the bat, an
> ls inside an "effective ls", assuming those greps
> somehow do what you want.
>
> Why not simply sort them all, using a sort that allows
> you to pass an expression that decides on whether
> a or b is bigger, in which you do a tr or toLower
> or whatever, but it's the UNmodified values that
> end up coming out the sort-order that didn't consider
> case, then one final run-through of those "sorted"
> results, and within every "run" of again tr'd or
> toLowered, if they differ in their original form,
> you've found at least one of what you're looking for.
>
> What's that so far, n log n + n?
>
>
> Or, if you want more info, then for each of
> those toLower'd runs, you sort THAT, "straight",
> then basically run a "uniq" on that.
>
> (If you're running a million strings through it,
> I suppose you'd code the uniq by hand, "in line",
> because of all the start-up time for the process start-ups.
>
> Or maybe depending on the length of the run you
> choose which to do.
>
> Maybe ditto for that inner sort.
>
>
> Question: does ANY of that make sense? As soon
> as I post this, I'll probably realize it's all wet!
>

Maybe this is a 'little' better?

uniq_lcnames=$(ls | dd conv=lcase 2>/dev/null | sort | uniq -d)

ls | grep -F -i "$uniq_lcnames"

Normal caveats about filenames with newlines.
From: jellybean stonerfish on
On Mon, 22 Feb 2010 03:30:59 +0000, jellybean stonerfish wrote:

> On Mon, 22 Feb 2010 02:15:08 +0000, David Combs wrote:
>
>>>Usual caveat about file names that contain newlines.
>> That is a joke, yes? Although I wouldn't put it past Windows to
>> allow it!

Acording to http://en.wikipedia.org/wiki/Comparison_of_file_systems
ntfs allows any Unicode except null and /

>
> I don't know about windows, but I do now that newlines are valid
> characters on linux with ext3. As are tab and backspace.

and ext3 allows any byte except NUL

From: Jon LaBadie on
jellybean stonerfish wrote:
> On Mon, 22 Feb 2010 03:30:59 +0000, jellybean stonerfish wrote:
>
>> On Mon, 22 Feb 2010 02:15:08 +0000, David Combs wrote:
>>
>>>> Usual caveat about file names that contain newlines.
>>> That is a joke, yes? Although I wouldn't put it past Windows to
>>> allow it!
>
> Acording to http://en.wikipedia.org/wiki/Comparison_of_file_systems
> ntfs allows any Unicode except null and /
>
>> I don't know about windows, but I do now that newlines are valid
>> characters on linux with ext3. As are tab and backspace.
>
> and ext3 allows any byte except NUL
>

You missed footnote 4 which says these restrictions are for the
file system's directory structure on disk, but that drivers and
OSs may add other restrictions. Specifically mentioned were
UNIX-like systems disallowing '/' and MS-DOS/WINDOWS disallowing
'\:?*"><|' in addition to those you mention.
From: jellybean stonerfish on
On Mon, 22 Feb 2010 12:41:09 -0500, Jon LaBadie wrote:

> jellybean stonerfish wrote:
>> On Mon, 22 Feb 2010 03:30:59 +0000, jellybean stonerfish wrote:
>>
>>> On Mon, 22 Feb 2010 02:15:08 +0000, David Combs wrote:
>>>
>>>>> Usual caveat about file names that contain newlines.
>>>> That is a joke, yes? Although I wouldn't put it past Windows to
>>>> allow it!
>>
>> Acording to http://en.wikipedia.org/wiki/Comparison_of_file_systems
>> ntfs allows any Unicode except null and /
>>
>>> I don't know about windows, but I do now that newlines are valid
>>> characters on linux with ext3. As are tab and backspace.
>>
>> and ext3 allows any byte except NUL
>>
>>
> You missed footnote 4 which says these restrictions are for the file
> system's directory structure on disk, but that drivers and OSs may add
> other restrictions. Specifically mentioned were UNIX-like systems
> disallowing '/' and MS-DOS/WINDOWS disallowing '\:?*"><|' in addition to
> those you mention.

That explains why I could not get a '/' in a filename. I was trying
to make a directory with a name of '/dirname'. I was going to see if
I could put it in my home directory and then cd into it, use it, or
delete it. I also had some difficulty getting a backtick ` in a
filename. Perhaps I need to try a better escape.


directory and then try to figure out how to read it or delete it