[NTLUG:Discuss] True order of files in a directory.
Richard Geoffrion
ntlug at rain4us.net
Tue Aug 30 01:54:06 CDT 2005
Steve Baker wrote:
>>>
>
>
>> If the order is based on the creation time, couldn't you just modify the
>> ctime to change the order?
>
>
> No - it's literally the order the files were created. The first file to
> come along grabs the first directory 'slot', the second one grabs the
> second.
> Subsequently changing the creation time doesn't affect which file got
> which
> slot.
Ok..then why doesn't this exercise work to put the files in order.
------------
#Make a brand new directory
mkdir /home/sorted
#change to the location of some unsorted files located on a different
file system
cd /usr/local/bin
#list the files in the source directory in alphabetical order and do a
# copy on each one of them in order (don't list the files in subdirs)
for i in `ls -d *` ; do cp $i /home/sorted/ ; done
#examine the results and note they are not in alphabetical order.
ls -fla /home/sorted
------------
Other tests that didn't work:
for i in * ; do cp $i /home/sorted ; done
----
mkdir /usr/local/sorted #on the same filesystem
for i in * ; do cp $i ../sorted ; done
----
#Try to MOVE them this time.
for i in * ; do mv $i ../sorted ; done
==================
From what I can see, bash/reiserfs is doing something ELSE when it
stores these files.
For grins I did the following.
mkdir /tmp/sorttest
cd /tmp/sorttest
touch 5
touch 2
touch 1
touch 4
touch 3
#and when I did..
ls -fla
#they were all in ..well...numerical order.
...Conclusion... Neither file creation NOR file placement into a
directory has one iota of influence on the 'raw' nature of the directory
sort.
So, if the 'true' order of the files from Linux using 'ls -f' (which
turns off sorting)
and when I do that, Linux sees the same random ordering
So.....how DOES one accomplish copying files in alphabetical order do a
removable media storage device? Does it require a file system tool?
maybe something that would sound like it would have the name --
reiserfssort/ext2sort/ext3sort? I wonder if any of my above examples
would work on a fat/fat32 filesystem...hm.. I should find some space and
test.
--
Richard
More information about the Discuss
mailing list