The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to get yesterdays julian date er_ashu UNIX for Dummies Questions & Answers 3 01-24-2009 01:20 PM
convert Julian date to calender date srikanthus2002 Shell Programming and Scripting 6 05-08-2007 07:27 AM
Find julian date for given corresponding date srikanthus2002 Shell Programming and Scripting 2 10-10-2006 10:33 PM
Calendar date to Julian and Back BCarlson Shell Programming and Scripting 4 05-14-2005 06:18 PM
Julian Date lesstjm Shell Programming and Scripting 3 04-17-2003 04:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-13-2009
1buckeye_fan 1buckeye_fan is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 7
need help using find and date (julian)

I'm trying to put together a little script that will move some files to a directory, uncompress the file then delete the file when processing is complete.

The files are all named using julian date

2009072.Z
2009071.Z
2009070.Z
2009069.Z
2009068.Z
2009067.Z
2009066.Z
2009065.Z
2009064.Z
2009063.Z
2009062.Z
2009061.Z
2009060.Z
2009059.Z
2009058.Z
2009057.Z

each day the oldest file falls off and the next day takes the lead.

I'm trying to find a way that will find the file with todays julian date, cp to another directory, uncompress, run another script on this uncompressed file, delete the file and then return to master directory to copy the next file over.

I can't mass cp the files because of size restrictions so I have to handle each file one at a time.

Thoughts or ideas would be very appreciated.

Thanks!
  #2 (permalink)  
Old 03-13-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,759
From today -> files in the past for one year.
Code:
cd /someplace
start=$( date +%Y%03j )
stop=$(  date +%Y000 )
while [[ $start -gt $stop ]]
{
     if [[ -f ${start}.Z ]] ; then
       cp ${start}.Z /anotherplace
       my_other_script.sh /anotherplace/${start}.Z
       rm -f /anotherplace/${start}.Z
       start=$(( $start - 1 ))
     else
           echo "${start}.Z not found .. skipping on to the next file "
    fi
}
  #3 (permalink)  
Old 03-16-2009
1buckeye_fan 1buckeye_fan is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 7
thanks for the reply but I have a question...

You have
start=$( date +%Y%03j )
stop=$( date +%Y000 )


shouldn't that line actually be
start=$( date +%Y365 )
stop=$( date +%Y000 )
  #4 (permalink)  
Old 03-16-2009
1buckeye_fan 1buckeye_fan is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 7
here is what I'm working with now...

Code:
cd /cms/ech_data/archive
start=$( date +%Y%j )
stop=$(  date +%Y000 )
while [[ $start -gt $stop ]]
do
    cp ${start}.Z ../recovery
    cd ../recovery
    uncompress ${start}.Z
    cpio -ivm < ${start}
    rm ${start}
    * touch   this is an error also  touch [filename] is the syntax 

for file in `ls chr*`
        do
        /export/home/ech/OA_resend $file
        echo $file
        rm $file
        done
        start=$(( $start - 1 ))
done

this script generates this error
syntax error at line 10 : `while' unmatched

Last edited by jim mcnamara; 03-16-2009 at 12:32 PM..
  #5 (permalink)  
Old 03-16-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,759
Please see the changes in red.
  #6 (permalink)  
Old 03-16-2009
1buckeye_fan 1buckeye_fan is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 7
thanks... I'm still missing something and I can't see what it is...

I'm trying to run the script in debug mode -x but it looks like I need to insert some pauses so I can read what the output is...

How can I pause the script at different points in the script?
  #7 (permalink)  
Old 03-16-2009
1buckeye_fan 1buckeye_fan is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 7
never mind.. I think I found what I need....
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0