UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 15th, 2005, 05:29 AM
izza_azhar izza_azhar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 49 izza_azhar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 33 m 57 sec
Reputation Power: 4
process file in diffrent directory

let say i have 1 directory that have 3 folders in it such
1.log--b2b/dsc
2.processed--b2b/processed
3.dsc--b2b/logs

last time, i used to write the same script for 3 different folder
for FILE in *_7B1*

do
curr_year=$(date +%Y)
curr_month=$(date +%Y%m)
file_year=$(echo $FILE| cut -d'_' -f4|cut -c 1-4)

file_month=$(echo $FILE|cut -d'_' -f4|cut -c 1-6)

if [[ $curr_year = "$file_year" ]]
then
if [ `expr $curr_month - 3` -ge $file_month ]
then
echo $FILE
mv $FILE /u006/r45647/Izza/b2b/dsc/archivedsc
echo "file transfer complete"
fi

fi

-------------------------------------
my question is how i'm gonna use just 1 script to all the directories?
means that ,
1) the script will go from 1 directory to another directory.
2)in the script itself..it will move the files into another directory that i already created
eq: in folder b2b/dsc-->the file will be move to b2b/dsc/archivedsc
it looks like simple.. but i donno how to solve it!
please

Reply With Quote
  #2  
Old February 15th, 2005, 12:53 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,307 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 28 m 57 sec
Reputation Power: 48
I made up folder names - try this
Code:
for folder in /path1/folder1 /path1/folder2 /path1/folder3
do
     cd $folder
     for FILE in *_7B1* 
     do 
        curr_year=$(date +%Y) 
        curr_month=$(date +%Y%m) 
        file_year=$(echo $FILE| cut -d'_' -f4|cut -c 1-4) 

        file_month=$(echo $FILE|cut -d'_' -f4|cut -c 1-6) 
        ............... insert rest of code here.
     done
     cd -
done


Use code tags next time, you'lll get more complete answers.

Reply With Quote
  #3  
Old February 16th, 2005, 11:22 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 44 m 45 sec
Reputation Power: 9
no answers, just a Q
assumed you are not working on december 31 23.59.59 (maybe you should check it)
and the progs take < 1 second
why do you recalculte the year && month in a loop ?
__________________
working on Solaris[5-9], preferred languages french and C.

Reply With Quote
  #4  
Old February 21st, 2005, 07:32 PM
izza_azhar izza_azhar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 49 izza_azhar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 33 m 57 sec
Reputation Power: 4
ok...

Quote:
Originally Posted by guggach
no answers, just a Q
assumed you are not working on december 31 23.59.59 (maybe you should check it)
and the progs take < 1 second
why do you recalculte the year && month in a loop ?


because the program will move the 3 months ago files.. so i just thinking calculating the day only..that was 92 days rite?

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > process file in diffrent directory


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway