I use this often:-
ls -Flatr
...since it sorts by date, hence putting my most recent stuff at the bottom.
I also often do this:-
ls -Flatr `slocate somefile`
... to find every occurance of a particular file, which "ls" then kindly sorts, leaving my most recent version of it at the bottom.
If, however, directories or files contain spaces, it fails.
How do I pass paramaters containing spaces to commands???
Note: I do not want to the cammand multiple times (once with each file) - I want to run the command once - passing all the files to it.
Here's an example:
$ ls -Flatr
total 16
drwxrwxrwt 23 root root 4096 Sep 4 10:30 ../
drwxrwxr-x 2 cnd cnd 4096 Sep 4 10:33 my dir/
drwxrwxr-x 4 cnd cnd 4096 Sep 4 10:33 ./
drwxrwxr-x 2 cnd cnd 4096 Sep 4 10:34 anotherdir/
$ ls -Flatr my\ dir/
total 12
-rw-rw-r-- 1 cnd cnd 8 Sep 4 10:33 my file
drwxrwxr-x 2 cnd cnd 4096 Sep 4 10:33 ./
drwxrwxr-x 4 cnd cnd 4096 Sep 4 10:33 ../
$ ls -Flatr anotherdir/
total 12
drwxrwxr-x 4 cnd cnd 4096 Sep 4 10:33 ../
-rw-rw-r-- 1 cnd cnd 8 Sep 4 10:33 myfile
drwxrwxr-x 2 cnd cnd 4096 Sep 4 10:34 ./
$ find . -name '*file' -print
./my dir/my file
./anotherdir/myfile
$ ls -Flatr ./my\ dir/my\ file ./anotherdir/myfile
-rw-rw-r-- 1 cnd cnd 8 Sep 4 10:33 ./my dir/my file
-rw-rw-r-- 1 cnd cnd 8 Sep 4 10:33 ./anotherdir/myfile
$ ls -Flatr `find . -name '*file' -print`
ls: ./my: No such file or directory
ls: dir/my: No such file or directory
ls: file
./a: No such file or directory
ls: o: No such file or directory
ls: herdir/myfile: No such file or directory
$ perl -e "print './my\ dir/my\ file ./anotherdir/myfile'"
./my\ dir/my\ file ./anotherdir/myfile
$ ls -Flatr `perl -e "print './my\ dir/my\ file ./anotherdir/myfile'"`
ls: ./my: No such file or directory
ls: dir/my: No such file or directory
ls: file: No such file or directory
ls: ./a: No such file or directory
ls: o: No such file or directory
ls: herdir/myfile: No such file or directory
$ ls -Flatr "my dir"
total 12
-rw-rw-r-- 1 cnd cnd 8 Sep 4 10:33 my file
drwxrwxr-x 2 cnd cnd 4096 Sep 4 10:33 ./
drwxrwxr-x 4 cnd cnd 4096 Sep 4 10:33 ../
$ perl -e 'print "\"my dir\""'
"my dir"
$ ls -Flatr `perl -e 'print "\"my dir\""'`
ls: "my: No such file or directory
ls: dir": No such file or directory
$
As you can see - "bash" seems to be "noticing" that my backtics are there, and even when I ensure my input paramaters are OK - it still stuffs things up (it seems to be attempting to "escape" everything in the `` input, even though it doesn't do this when I type it in)
Arrrrgh.
all help much appreciated!
I'm using RedHat ES3 and GNU bash, version 2.05b.0(1)-release-(i386-r
edhat-linu
x-gnu)