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 > SubString of a file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-15-03, 13:17
thejeffe thejeffe is offline
Registered User
 
Join Date: Dec 2003
Posts: 2
SubString of a file

I am trying to get the string contained in a row/col location of a text file.

Example
01 02 03 04 05 06 07 08 09 00
11 12 13 14 15 16 17 18 19 10
21 22 23 24 25 26 27 28 29 20

the string at row 2 col 3 length 2 is 12.

I need to to do some script redirection according to what text is contained ina text file, i.e. what type of form the user has printed.

I am using ksh and am open to other solutions.
Reply With Quote
  #2 (permalink)  
Old 12-15-03, 15:38
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
may be I am wrong, but at row 2 col 3 length 2 I see the 13 and not 12.

Please give some more examples to what you want. I dont understand the second part.
__________________
Greetings from germany
Peter F.
Reply With Quote
  #3 (permalink)  
Old 12-15-03, 16:00
thejeffe thejeffe is offline
Registered User
 
Join Date: Dec 2003
Posts: 2
For example I have the following text file:

Quote:

Invoice - Return Merchandise *** D U P L I C A T E ***
000000 108560-00
2040
10/31/02 01-024 1
I would like a line in the script to return a true if the word Invoice is located in row 1 colum 12. Other forms could have Quote, Purchase Order, etc... in the same location. I am to do something dfferent for each different form.

thanks
Reply With Quote
  #4 (permalink)  
Old 12-16-03, 01:23
pooja pooja is offline
Registered User
 
Join Date: Dec 2002
Posts: 104
Quote:
Originally posted by thejeffe
For example I have the following text file:



I would like a line in the script to return a true if the word Invoice is located in row 1 colum 12. Other forms could have Quote, Purchase Order, etc... in the same location. I am to do something dfferent for each different form.

thanks
hi!

just a try to ur problem,

i understand that at row 1 col 12 there can be values like invoice,Quote,Purchase Order,etc. and depending on these values u need to call different script/redirection(correct me if i am wrong)

if my understanding is correct then u can extract what is contained in row1 col12 using it

val=`awk '{ if (NR==1) print $12}' filename.txt`

now $val contains values like Invoice/Quote/PurchaseOrder

now u can use case on $val values and do redirection accordingly.

hope this is what u want.
--Pooja
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