| Author |
emulate ls -Q functionality with find?
|
|
| usr.bin.python@gmail.com 2006-01-29, 9:31 pm |
| I would like to do a (recursive) find that automatically escapes /
quotes its output, is this possible?
# ls -Q1
"bin"
"boot"
"dev"
"etc"
"home"
"lib"
"lost+found"
....
| |
| usr.bin.python@gmail.com 2006-01-29, 9:31 pm |
| > I would like to do a (recursive) find that automatically escapes /
> quotes its output, is this possible?
> # ls -Q1
> "bin"
> "boot"
> ...
ok... I realized 3 seconds after posting this that I can do the
following:
# find /usr/ -exec ls -Q {} \;
....
"/usr/X11R6/lib/libXss.so.1"
"/usr/X11R6/lib/libXmu.so.6"
"/usr/X11R6/lib/libXxf86rush.so.1.0"
"/usr/X11R6/lib/libGL.so.1.2"
"/usr/X11R6/lib/libXevie.a"
....
| |
| usr.bin.python@gmail.com 2006-01-29, 9:31 pm |
| > # find /usr/ -exec ls -Q {} \;
> ...
> "/usr/X11R6/lib/libXss.so.1"
> "/usr/X11R6/lib/libXmu.so.6"
> "/usr/X11R6/lib/libXxf86rush.so.1.0"
> "/usr/X11R6/lib/libGL.so.1.2"
> "/usr/X11R6/lib/libXevie.a"
> ...
sorry for the spam, that should be:
# find /usr/ -exec ls -Qd {} \;
| |
| Stephane CHAZELAS 2006-01-29, 9:31 pm |
| 2006-01-26, 13:03(-08), usr.bin.python@gmail.com:
>
> ok... I realized 3 seconds after posting this that I can do the
> following:
>
> # find /usr/ -exec ls -Q {} \;
> ...
> "/usr/X11R6/lib/libXss.so.1"
> "/usr/X11R6/lib/libXmu.so.6"
> "/usr/X11R6/lib/libXxf86rush.so.1.0"
> "/usr/X11R6/lib/libGL.so.1.2"
> "/usr/X11R6/lib/libXevie.a"
> ...
You may want to add the -d option to ls though and replace \;
with + to avoid having find call ls for every single file.
in zsh:
files=(/usr/**/*(D))
print -rl ${(qqq)files}
--
Stéphane
| |
| Xicheng 2006-01-29, 9:31 pm |
| usr.bin.python@gmail.com wrote:
> I would like to do a (recursive) find that automatically escapes /
> quotes its output, is this possible?
> # ls -Q1
> "lib"
> "lost+found"
how about this:
find . | PERL -F/ -alne 'print qq("$F[$#F]") unless /^\.$/'
this strips off all the directory info from the filename...
Xicheng
|
|
|
|