[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: bash scripting question -- passing values to ls



On Sun, Jan 04, 2004 at 02:27:11AM -0500, Matt Price wrote:
> hey folks,
> 
> 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...
> 
> so I have to do it by hand at the moment.  But shouldn't I be able to
> automate it with somthing like:
> 
> ls < locate charter | grep -i font 
> ?
> nothing I try works -- but I can't believe  it's impossible!  any
> hints?
> 
> thx,
> matt
> 
Hi Matt,
I use a little bash code over and over again.
Its a while loop.

locate charter| grep -i font | while read line; do
	ls -l $line;
done

It has many uses and it doesnt have a limit like xargs.
I found out about xargs but started having problems that it could not
solve so I came up with this!
Have fun with Bash! It's Bourne-Again!
-Kev

Attachment: signature.asc
Description: Digital signature


Reply to: