Now this is for a seriously broken system. Unfortunetly, some systems do not like that,Ĭat list-of-all-file-to-search-for.txt | split -help -a 4 -d -l 2000 file-smaller-chunk.part. IF your shell handles large size lists nicely,įor file in cat list-of-all-file-to-search-for.txt do grep REGEXP_PATTERN "$file" ĭone is a nice way to get by. So we avoid xargs in such systems (i know, i know, just lets pretend it is broken ).įind /whatever/dir/to/start/looking/ -type f > list-of-all-file-to-search-for.txt We need to exec grep for each file,and this is normaly the wrong way.Īssume : xargs is broken OR not available.įirst, if you have a buggy pipe, it might not handle large number of files. ![]() This is not available (for whatever valid reason), We prefer find /somedir/ -type f -print0 |xargs -0 grep -f 'patternfile.txt' approach, but since Some may prefer xargs instaed (unless you happen to have buggy xargs). Under normal situations, even when grep -r is broken, find /dir/ -exec grep \ should work. Will escape all characters and enclose it with (|) brackets so a regexp OR match will be performed. ![]() We use grep "$(echo -en "ESCAPED_PATTERN" )" to do our job.īuilding a escaped regexp pattern (using hexdump as example ) Feed the escaped pattern into broken regexpĪssuming the bare minimum shell escape is available, (example does not print special char, but it's there.) we must turn it into something likeĪssuming echo -en command is not broken, and xxd, or od, or hexdump is available,Ĭat patternfile.txt |hexdump -ve '1/1 "%02x \n"' |tr -d '\n'Ĭat patternfile.txt |od -A none -t x1|tr -d '\n'Īnd pipe it into (common for both hexdump and od) Convert list into a regexp that grep likes But lets be on the safe side.Īssume : working sed ,one of od OR hexdump OR xxd (from vim package) is available.ġ. Under normal situations, grep -rf patternfile.txt /some/dir/ is the way to go.Ī file containing a list of all the strings to be searchedĪssumptions : gnu coreutil not available. ![]() I assume (for some reason) the system is broken, and escapes do not work as expected. By reading, I assume we can not use the gnu coreutil, and egrep is not available.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |