Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #problem: grep gives "memory exhausted" error on 6TB disks
- ##solution: read it on parts
- if [ -z $2 ] || ! [ -e $1 ]; then echo "$0 file string|less -S # greps in chunks"; exit; fi
- FILE="$1"
- MATCH="$2"
- nlines=$(wc -l < $1)
- chunk=1000
- LC_ALL=C
- for((i=1; i < nlines; i += chunk))
- do
- sed -n $i,+$((chunk - 1))p $1 | grep -F -a -z -C 500 $2
- done
Advertisement
Add Comment
Please, Sign In to add comment