Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Shell


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Shell
Date   Fri, 6 May 2005 13:07:11 +0100

I guess you need to try to fool the parser
by, as it were, smuggling your slash through 
customs without it being spotted. 

I'd try 

local slash "/" 

... 

! rm ${temp}`slash'*.* 

in the hope that the splitting off of 
comments precedes the interpretation of 
the local macro. 

Nick 
[email protected] 

Neil Shephard replied to Hans J. Baumgartner 
 
> > I am using Stata8 on a Unix machine.
> > 
> > I am using the a shell to erase some files, but while doing 
> so Stata does
> > not find the end of the loop. Why?
> > 
> > Example
> > 
> > foreach x in ? {
> >         do something
> >         ! rm ${temp}/*.*
> > }
> > 
> > Stata does not read the closing bracket.
> > 
> 
> Stata's not seeing the end of the loop becuase it see '/*' as the
> start of a comment section and anything that follows is ignored until
> there is a closing '*/'
> 
> I've encountered this before, and couldn't work out any sort of
> general solution.  I resolved the problem by replacing *.* with a
> small amount of text that was common to the leading part of the
> filename.  This may require you to slightly modify the do-file that
> you are calling within the loop, so that temporary files carry a
> prefix.  For example...
> 
> foreach x in ?{
>    do something
>    !rm ${temp}/_*.*
> }
> 
> ...would workaround this problem.
> 
> I guess you could escape the forward slash that follows the leading
> bracket, but I can't find anything, and using the backslash to escape
> it (i.e. !rm ${temp}\/*.*) does not work.
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index