The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



Thread: For cycle
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 06-08-2007
anbu23 anbu23 is offline
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Quote:
Originally Posted by nagomes
Hello,

I have files in a dir.

I what to create a FOR cycle that will do this

FOR <condition> do
file=`ls <directory> | tail -1`
echo $file
mv -f $file <another dir>
done

What I want to now is what should I put in the <condition>. The condition I want is that the FOR will execute until there is no more files in the directory

Thanks
If you want to move all files from one directory to another
Code:
mv -f /dir1/* /dir2
Reply With Quote