Go Back   The UNIX and Linux Forums > Operating Systems > Solaris


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #8  
Old 10-04-2012
elixir_sinari's Avatar
Gotham Knight
 
Join Date: Mar 2012
Location: India
Posts: 1,372
Thanks: 87
Thanked 478 Times in 458 Posts
May be Jim missed something...

Code:
dest=/path/to/september/
touch -t 201209010000 /tmp/d1
touch -t 201209302359 /tmp/d2
find /path/to/files -type f -newer /tmp/d1 \! -newer /tmp/d2 | while read fname
do
     mv "$fname" "$dest"
done

    #9  
Old 10-04-2012
Registered User
 
Join Date: Jun 2010
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks elixir!

It is working fine for the september files. I need to move the other month files also needs to be moved to the respective folders.

Please help me to do this.

---------- Post updated at 09:03 AM ---------- Previous update was at 08:59 AM ----------

Quote:
Originally Posted by elixir_sinari View Post
May be Jim missed something...

Code:
dest=/path/to/september/
touch -t 201209010000 /tmp/d1
touch -t 201209302359 /tmp/d2
find /path/to/files -type f -newer /tmp/d1 \! -newer /tmp/d2 | while read fname
do
     mv "$fname" "$dest"
done

I have an idea like first we have to find the list of files from the directory. then we have to get the month of the file using awk {print $6} and based on the month we have to move our files.

pls help me such a way to resolve this issue. Thanks!
    #10  
Old 10-05-2012
itkamaraj's Avatar
^Kamaraj^
 
Join Date: Apr 2010
Posts: 3,025
Thanks: 33
Thanked 647 Times in 625 Posts

Code:
ls -lrt | awk -v '/^\-/{print $6,$NF}' | while read month filename
do
        mkdirp -p /full/path/${month}_bkp_files
        mv ${filename} /full/path/${month}_bkp_files
done

    #11  
Old 10-05-2012
Registered User
 
Join Date: Jun 2010
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by itkamaraj View Post
Code:
ls -lrt | awk -v '/^\-/{print $6,$NF}' | while read month filename
do
        mkdirp -p /full/path/${month}_bkp_files
        mv ${filename} /full/path/${month}_bkp_files
done

Thanks!

mv: cannot stat 'test.edi': No such file or directory

getting the above error
Closed Thread

Tags
script from ksh, solaris 10

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Move files to Folders diva_thilak Shell Programming and Scripting 5 07-23-2009 01:53 AM
Move folders containing certain files xavix UNIX for Dummies Questions & Answers 3 02-21-2009 05:43 AM
How do you move lines of numbers based on the month terryporter51 Shell Programming and Scripting 11 06-15-2008 12:54 AM
how to move files into different folders based on filename italia5 UNIX for Dummies Questions & Answers 7 08-23-2006 10:04 AM



All times are GMT -4. The time now is 05:03 PM.