Вот мое решение, как отправлено в моем комментарии к ответу Тора:
awk -v M="`wc -L file`" '{ printf "%*s%*s", (M+length)/2, $0, (M-length+1)/2+1, "\n" }' < file
Я чувствую, что это решает проблему изящно и кратко, и поэтому я повторно отправляю его как ответ.
Это хорошая утилита, часть Linux-Ftools . Вы должны дать имя файла в качестве ввода, и он будет статистика для файлов, которые находятся в кэше сейчас.
# FINCORE --Pages = FALSESAMARIZE - DLY-CACHED
fincore [options] files...
--pages=false Do not print pages
--summarize When comparing multiple files, print a summary report
--only-cached Only print stats for files that are actually in cache.
root@xxxxxx:/var/lib/mysql/blogindex# fincore --pages=false --summarize --only-cached *
stats for CLUSTER_LOG_2010_05_21.MYI: file size=93840384 , total pages=22910 , cached pages=1 , cached size=4096, cached perc=0.004365
stats for CLUSTER_LOG_2010_05_22.MYI: file size=417792 , total pages=102 , cached pages=1 , cached size=4096, cached perc=0.980392
stats for CLUSTER_LOG_2010_05_23.MYI: file size=826368 , total pages=201 , cached
---
total cached size: xxx
также TMPFS или RAMFS файловая система является частью кеша.
Как отмечено в документации TMPFS
Since tmpfs lives completely in the page cache and on swap, all tmpfs
pages currently in memory will show up as cached. It will not show up
as shared or something like that
tmpfs has three mount options for sizing:
size: The limit of allocated bytes for this tmpfs instance. The
default is half of your physical RAM without swap.
**If you oversize your tmpfs instances the machine will deadlock
since the OOM handler will not be able to free that memory.**
nr_blocks: The same as size, but in blocks of PAGE_CACHE_SIZE.
nr_inodes: The maximum number of inodes for this instance. The default
is half of the number of your physical RAM pages, or (on a
machine with highmem) the number of lowmem RAM pages,
whichever is the lower.
, вы можете ограничить файловую систему TMPFS
# Mount -T TMPFS -O Size = 60 м TMPFS / TMP -> Размер, ограниченный до 60 м
Вы также можете настроить Ваши записи / proc / sys / vm / * для лучшего механизма кэширования.
Я написал сообщение в блоге здесь о кэшировании Linux . Вероятно, это может помочь вам.