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

Re: OT: shell scripts and spaces in file/folder names



* Jan Trippler (Jan.Trippler@t-online.de) [030418 00:33]:
> ... and try
> 
> for i in *
> 
> instead of 
> 
> for i in `ls *`
> 
> You don't need to start a ls command to expand the * - the bash
> itself can do it.

More to the point; bash expands the * in either case.  When using
`ls *`, the * is expanded into a file list which is passed to ls, which
just spits back the same file list.  It's a total waste.

Of course, also, for simple throwaway scripts like this one, I guarantee
that you won't notice the difference at all.  It's just good to get into
good habits and recognizing what is really going on when you use
constructs like `` to start subshells, etc.

good times,
Vineet
-- 
http://www.doorstop.net/
-- 
http://www.aclu.org/		It's all about Freedom.

Attachment: pgphk3rEWdxMV.pgp
Description: PGP signature


Reply to: