If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > how to split string?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-05, 22:48
izza_azhar izza_azhar is offline
Registered User
 
Join Date: Jan 2005
Posts: 8
how to split string?

my old program is using cut to get the date of the file such:
for FILE in ATK*
do
file_year=$(echo $FILE| cut -c 13-16)
file_month=$(echo $FILE|cut -c 13-18)
###
echo $file_month --->just as example!
done
where filename is such:
ATK_7B1_WIP_20041116160700.1.xml.dsc
ATK_7B1_WIP_20041116160700.2.xml.dsc
ATK_7B1_WIP_20041116160700.3.xml.dsc
ATK_7B1_WIP_20041116160700.4.xml.dsc

problem is how can i enhance it to all filename?
such:
AIT_7B1_WIP_20050101010101.dsc
ASECL_7B1_WIP_20041209151027.xml.dsc
ASEKR_7B1_WIP_20050101020202.dsc

so i cant use the ' for FILE in ATK* ' rite?
should replace with what?
all the filename will be the same unless the front name:
xxxx_7B1_WIP_20041116160700xxx
help!!!
Reply With Quote
  #2 (permalink)  
Old 02-07-05, 23:02
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
Code:
for FILE in ATK*
do
    date=$(echo ${FILE} | sed -e 's/.*_\([0-9][0-9]*\).*/\1/g')
    file_year=$(echo $date| cut -c 1-4)
    file_month=$(echo $date|cut -c 5-6) 
    .......
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On