grep command options
I wanted to search my whole drive for a string. Following the accepted answer in Stack Overflow I used:
sudo time grep -rnw '/' -e 'Sony 50"'
and it took 53 Hours to process 20 GB of data on one of the fastest PCIe NVMe M.2 SSD's around; Samsung Pro 960.
grep output log
grep processes some files it generates error messages. These can be suppressed by appending
2>/dev/null to the command. However the errors give feedback on progress being made. Some of the sample output (it won't all fit) is below:
Binary file /home/Me/.config/google-chrome/Default/Sync Data/SyncData.sqlite3 matches grep: /sys/kernel/security/ima/policy: Permission denied grep: /sys/kernel/slab/:dt-0000008/alloc_calls: Function not implemented grep: /sys/kernel/slab/:dt-0000008/free_calls: Function not implemented (... SNIP ... 12 hours later PID 882 processed below...) grep: /proc/882/task/922/attr/sockcreate: Invalid argument grep: /proc/882/task/923/mem: Input/output error (... SNIP ... 24 hours later PID 2954 below...) grep: /proc/2598/attr/sockcreate: Invalid argument grep: /proc/2954/task/2954/mem: Input/output error (... SNIP ... 42 hours later PID 4396 below...) grep: /proc/4389/attr/sockcreate: Invalid argument grep: /proc/4396/task/4396/mem: Input/output error (... SNIP ... After 53 hours `grep` finally finishes...) grep: /run/user/1000/gvfs: Permission denied Command exited with non-zero status 2 97355.34user 83223.12system 53:07:40elapsed 94%CPU (0avgtext+0avgdata 31116maxresident)k 593910020inputs+0outputs (1major+10731minor)pagefaults 0swaps
grep gives impression it's frozen
Sometimes I thought
grep was frozen because the screen didn't update for an hour and the hard disk light didn't flash much. However Conky tells me it is still running and taking 100% CPU on a single core, as seen in this GIF.
Of the 19.5 GiB out of 43.8 GiB being used on the Linux (Ubuntu 16.04.3 LTS) partition, half of this space, 10 GB are used by kernels. Downloading and testing kernels is my pass-time.
This test took most of my week-end plus Monday to complete.
How can I speed up
grep and still get what I'm looking for?