This is also possible using the vmtouch Virtual Memory Toucher utility.
The tool allows you to control the filesystem cache on a Linux system. You can force or lock a specific file or directory in the VM cache subsystem, or use it to check to see what portions of a file/directory are contained within VM.
How much of the /bin/ directory is currently in cache?$ vmtouch /bin/ Files: 92 Directories: 1 Resident Pages: 348/1307 1M/5M 26.6% Elapsed: 0.003426 seconds
Or...
Let's bring the rest of big-dataset.txt into memory...$ vmtouch -vt big-dataset.txtbig-dataset.txt[OOo oOOOOOOO] 6887/42116[OOOOOOOOo oOOOOOOO] 10631/42116[OOOOOOOOOOOOOOo oOOOOOOO] 15351/42116[OOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 19719/42116[OOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 24183/42116[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 28615/42116[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 31415/42116[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 36775/42116[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 39431/42116[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 42116/42116 Files: 1 Directories: 0 Touched Pages: 42116 (164M) Elapsed: 12.107 seconds