in reply to Specified Line Searching in file!
If you lines are sorted by it's ID in the file, then use binary search, overvise try:
#!/usr/bin/perl -nw use constant ID => 'id_tag'; # ID what you searching use constant ID_LENGTH => length(ID); if (substr($_, 0, ID_LENGTH) eq ID ) { print "found:\n$_"; exit; }
Update: usage: script.pl BIG_FILE.txt
please tell how fast my code on your data, thanks
Update: If your big file contains constant data, then you may create an index file. The format of that file is :
Thus you are able to search a tag in the index file and fetch searched line using seek# [id_tag] [byte offset] id_tag1 0 id_tag2 123 id_tag3 463 ...
|
|---|