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 January 17th, 2005, 07:18 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
split string

if file name such:
ATK_7B1_WIP_20041116160700.9.xml.dat
ATK_7B1_WIP_20041116160700.93474039283928384.xml.dat
so how can i cut to only get the year,month,day and year and month

such:1) 2004
2) 200411

Reply With Quote
  #2  
Old January 17th, 2005, 09:16 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
continue..split string

let say my program such this:

for FILE in ls ATK*.dat
do
curr_year=$(date +%Y)
curr_month=$(date +%Y%m)
file_year=<filename just have the year>
file_month=<filename that just have year and month>

if [ "$curr_year" = "$file_year" ]
then
if [ 'expr $curr_month - $file_month >= 3 ]
then
mv $FILE /u006/r45647/Izza/xsltOutput/archiveprocess
<move the file to another directory>

fi

fi

done

can we use sen to pass the variable for $file_year or file month?
or it's easy use the cut only?

Reply With Quote
  #3  
Old January 18th, 2005, 06:34 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
Quote:
Originally Posted by izza_azhar
let say my program such this:
# which interpreter are you using ?

for FILE in ls ATK*.dat
# where are backstiks gone ?
do
curr_year=$(date +%Y)
curr_month=$(date +%Y%m)
# are CONSTANT so why re-compute in a loop ??
file_year=<filename just have the year>
file_month=<filename that just have year and month>

# learn regexpr using 'sed' or other tool to get this values


if [ "$curr_year" = "$file_year" ]
# the " are useless and confusing
# a 'case' statement will be more performant
then
if [ 'expr $curr_month - $file_month >= 3 ]
# here are errors, the ' is wrong AND not closed
# according the shell you start, >= is not valid
# did you realized, >=3 and >2 are the same ?
# i suppose should be '-gt 2'
then
mv $FILE /u006/r45647/Izza/xsltOutput/archiveprocess
<move the file to another directory>

# i don't understand this statement

fi

fi

done

can we use sen to pass the variable for $file_year or file month?
or it's easy use the cut only?


may kindly invite you; read a shell-prog book!

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > split string


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 1 hosted by Hostway