T
T
Twelfth Doctor2018-02-24 18:42:43
linux
Twelfth Doctor, 2018-02-24 18:42:43

How to set a limit on the size of files to be checked for grep?

Hello. Can you please tell me how to limit the size of the files to be checked for the grep command? Those. so that files larger than 20 mb (for example) are skipped?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
res2001, 2018-02-24
@verdex

Run through find - you can make a filter with findom and run grep on the files that have passed the filter.

K
ky0, 2018-02-24
@ky0

Make the grep command an alias to a script that checks the file size before execution and only then actually greps or gives an etc error. On the other hand, this can be simply bypassed by using a design cat filename | grep, etc.
For what purposes, in general, do you need it?

V
vponed, 2021-12-18
@vponed

sudo find /path -type f -size -100M -exec grep -i -a -l search_word_can_be_quoted {} \;
Here are those search for text in files with screening of the files themselves

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question