Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select record from their value in a certain position 2

Status
Not open for further replies.

Gloups

IS-IT--Management
Sep 16, 2003
394
FR
Hi all, i'm trying to select specific records from a file where the value at column 423 match a pattern i gave.

i tried with awk but separator carracters seem to be binary blank or something else, not space carracters and i havent got any output.

now needing new ideas

Thank's in advance
 
Hi

Gloups said:
i'm trying to select specific records from a file where the value at column 423 match a pattern i gave
Please consider those underlined terms unknown, then try to understand the task. It is abit obscure, isn't it ? Please give us more details.
Gloups said:
i tried with awk but separator carracters seem to be binary blank or something else, not space carracters and i havent got any output.
Separator of what, fields or records ? Please give us a sample input and desired output.

Feherke.
 
There is no separators the only information i have is the relativ position in the record.

When i said specific record it was because for example: I want to extract records wich have 20070101 in position 400
 
Have a look at the substr function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
to expand on the substr function that PHV mentioned, you could do something like this once you have read the line from the file:

code snippet:
Code:
SUBLINE=${LINE:399:8}
if [[ $SUBLINE = "20070101" ]]
  then
    <do some stuff>
fi

where LINE is read from the file
the 399 is the starting position (it counts from 0)
the 8 is the number of characters to "extract"

Note: if you are using KSH - depending on the verion - the above may not work. I have tested the above syntax with bash and it works correctly. YMMV.
 
Thank's for yout help to a poor sys admin :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top