Re: OT: bash scripting question -- passing values to ls
Matt Price <matt.price@utoronto.ca> writes:
> here's something that ocmes up a lot for me:
>
> I use locate to find a bunch of files:
>
> % locate charter | grep -i font
> /usr/share/texmf/fonts/afm/bitstrea/charter
> /usr/share/texmf/fonts/tfm/bitstrea/charter
> /usr/share/texmf/fonts/type1/bitstrea/charter
> /usr/share/texmf/fonts/vf/bitstrea/charter
>
> then I want to ls -l each of these files...
IMHO, the simplest way to do it is
locate charter | grep -i font | xargs ls -l
but that will fail if the filenames have spaces or other whitespace in
them. The very slow but reliable equivalent would be
find / -name charter -path '*charter*' -print0 | xargs -0 ls -l
or even
find / -name charter -path '*charter*' -ls
but that doesn't do the caching that locate does.
(Other people have given good suggestions about using backticks to do
this as well.)
--
David Maze dmaze@debian.org http://people.debian.org/~dmaze/
"Theoretical politics is interesting. Politicking should be illegal."
-- Abra Mitchell
Reply to: