LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > Skaperen
User Name
Password

Notices


Rate this Entry

a feature i would like to see added to grep

Posted 10-28-2022 at 06:20 PM by Skaperen
Tags grep

a feature i would like to see added to the grep family of commands (that is, to all of them) is the ability to specify a limit of how much of the file to scan for matching patterns/expressions. this would not be like the -m NUM/--max-count=NUM option, which counts what is actually matched. the limit i want to also see is effectively a limit of the size of the file. after this much of the file has been read, grep should behave as if the file ended. this would be the number of bytes unless the letter "l" or "L" is at the end of the number, after any size multipliers ("k", "m", "g", "t", "p" or upper case variants). the letter "l" or "L" would change the unit from bytes to lines.

the reason i would like to see this is that i often want to scan my 5 million and some files for some text i expect to find in some file(s) usually only in the first 4K or so. but about a million or so files are rather large, having a wide variety of names. even if a big file will match, it generally is only going to be in the first 4K or so. a significant fraction of those large files are over a gigabyte in size (hundreds of them). i hate having such a search take over an hour. it could run faster if it would quit scanning any file with no matches when it reaches 4K (or whatever number is requested).
Posted in Uncategorized
Views 410 Comments 1
« Prev     Main     Next »
Total Comments 1

Comments

  1. Old Comment
    That's what head and tail are for.
    Posted 10-31-2022 at 09:39 AM by GazL GazL is offline
 

  



All times are GMT -5. The time now is 02:23 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration