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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search and list information from files

Status
Not open for further replies.

mune77

Programmer
Oct 15, 2009
6
GB
I have a huge directory of files with some test data. I need to write a program to search only text files (with ".txt") and list the information. The text files contains instances as "ADDR #nnnn", where nnnn is four hex digits. The program should list the hex number against the number of instances that it's been found. please help me on this !
Thanks in advanced!
 
I am very new to TCL programming. I have only managed to establish the file search code and the pattern matching.
If this is something straight forward - please help me on to build the whole program.
 
Hi

Please note that we have to do our jobs for living.
mune77 said:
I have only managed to establish the file search code and the pattern matching.
So the remaining task is to count the occurrences. Post your code and I will guide you to complete it. But I have no time to reproduce your current code and generate sample input to test it.

Or just wait for someone else.


Feherke.
 
If your problem is with syntax, post your logic (aka pseudo code), step by step, and we can translate that to Tcl. I have to say, however, that as much as I love Tcl (and I do), it probably isn't the best language for this task (if I understand what this task is).

_________________
Bob Rashkin
 
Hi

Bob said:
I have to say, however, that as much as I love Tcl (and I do), it probably isn't the best language for this task (if I understand what this task is).
I have to agree. Personally I would do it with command line tools :
Code:
grep -h -o -E 'ADDR #[[:xdigit:]]{4}' *.txt | cut -d '#' -f 2 | sort | uniq -c
Tested with GNU [tt]grep[/tt], [tt]cut[/tt], [tt]sort[/tt], [tt]uniq[/tt].

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top