Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsI 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
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: ravenplPosted on 2005-09-04 at 04:12:39ID: 14818962
Comments are available to members only. Sign up or Log in to view these comments.