Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why grep command is taking less time when performing second time?

Tags:

linux

grep

When I do grep on a large local file, it took long time. But when I do it again, now it is much faster. Is this behaviour because of some type of internal cache maintained by Linux systems?

like image 984
kadina Avatar asked Aug 26 '26 10:08

kadina


2 Answers

Yes. All free ram is be used to cache data read from your harddisk.

like image 125
MTilsted Avatar answered Aug 29 '26 04:08

MTilsted


The virtual memory page cache will keep copies of pages from the disk in your RAM which means the access time is faster and the corresponding read/pread calls will be serviced from memory instead of having to go to disk.

like image 21
Jesus Ramos Avatar answered Aug 29 '26 03:08

Jesus Ramos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!