[NTLUG:Discuss] What's the bash equiv of the DOS for % in?
    Steve Baker 
    sjbaker1 at airmail.net
       
    Sun Aug 26 13:51:07 CDT 2001
    
    
  
Richard Geoffrion wrote:
> 
> DOS:  for %i in (*.*) do del ..\%i
> 
> English: For every instance of a file specified by the wildcard do command
> using that file
> 
> I don't want to delete every file in that subdirectory...just the files that
> I extracted.  So...if I sit in a directory that contains JUST the files that
> came out of the tar and I issue the above DOS command...only I need the
> LINUX version of it... I can automatically clean the files out of the
> trashed up directory.
Euww!  That's sneaky - and should work the same in Linux - the exact syntax
depends on which shell you use...but the same trick will work.
Personally, I would do things like that in easy steps in order to
avoid disasters.
FILES=*             -- Get a list of all the files in this directory
echo $FILES         -- (OPTIONAL) Take a look at the list so we are sure nothing bad gets killed
cd ..               -- Go up one level
rm $FILES           -- Trash those files!  (Maybe want some command line options to 'rm' depending
                       on what exactly you want...'-r' would be useful in this case.)
If you are using csh or tcsh, that first line is:
  setenv FILES *
----------------------------- Steve Baker -------------------------------
HomeMail : <sjbaker1 at airmail.net>   WorkMail: <sjbaker at link.com>
HomePage : http://web2.airmail.net/sjbaker1
Projects : http://plib.sf.net       http://tuxaqfh.sf.net
           http://prettypoly.sf.net http://tuxkart.sf.net
           http://freeglut.sf.net   http://toobular.sf.net
    
    
More information about the Discuss
mailing list