tmh@well.UUCP (Todd M. Hoff) (08/08/89)
Why doesn't this work: find . -type d -print -exec mkdir /xx/yy/zz/{} \; The '{}' doesn't expand out to the filename like you might expect. Yet this does work: find . -exec ls {} \;. '{} expands to the filenames and the files are listed. Why the difference? Config: RTs running BSD 4.3.
karish@forel.stanford.edu (Chuck Karish) (08/08/89)
In article <12502@well.UUCP> tmh@well.UUCP (Todd M. Hoff) wrote: >Why doesn't this work: > > find . -type d -print -exec mkdir /xx/yy/zz/{} \; > >The '{}' doesn't expand out to the filename ... Because the parser in find is too crude to recognize a token that's not delimited by white space. Try this, instead: find . -type d -print | sed 's+^+/xx/yy/zz/+' | xargs mkdir Chuck Karish {decwrl,hpda}!mindcrf!karish (415) 493-7277 karish@forel.stanford.edu
cpcahil@virtech.UUCP (Conor P. Cahill) (08/25/89)
In article <12502@well.UUCP>, tmh@well.UUCP (Todd M. Hoff) writes: > Why doesn't this work: > > find . -type d -print -exec mkdir /xx/yy/zz/{} \; > > The '{}' doesn't expand out to the filename like you might > expect. Yet this does work: find . -exec ls {} \;. '{} expands > to the filenames and the files are listed. 1. find looks for the {} as an explicit argument, not as a sub-part of another argument. I agree with you in that {} should be substituted even if it is a part of an argument. 2. The find . -exec ls {} \; will list all of the files twice (once when the directory is visited and once as it visits each file. Maybe you would want to use something like "find . -print". -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9240 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+