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!

find numeric character 1

Status
Not open for further replies.

mdraja

Programmer
Oct 14, 2003
44
GB
Hi,

I need to be able to read through a file and highlight all lines that have a numeric character in the 19th position.

Any help greatly appreciated
 
The awk way:
awk 'substr($0,19,1)~[0-9]' /path/to/file
The grep way:
grep -E '^.{19}[0-9]' /path/to/file

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
thanks PHV
You have been a legend mate
 
I think you would get errors unless....
[tt]
grep -E '^.{[red]18[/red]}[0-9]' /path/to/file
[/tt]
 
Also....
[tt]
awk 'substr($0,19,1)~[red]"[/red][0-9][red]"[/red]' /path/to/file
[/tt]
 
Good catch, Ygor. I'm feeling like a monday morning today.
Will try to do more test before posting.[blush]
 
thanks all

I noticed the 18 when I was applying the grep and I was initially always 1 charachter out ... but the principle got me there in the end

Thanks for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top