如何显示/proc中文件的大小?它不应该是零尺寸 [英] how can i show the size of files in /proc? it should not be size zero

查看:21
本文介绍了如何显示/proc中文件的大小?它不应该是零尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从下面的消息中,我们知道文件/proc/sys/net/ipv4/ip_forward中有两个字符,但是为什么ls只显示这个文件的大小为零?

from the following message, we know that there are two characters in file /proc/sys/net/ipv4/ip_forward, but why ls just showed this file is of size zero?

我知道这不是磁盘上的文件,而是内存中的文件,那么是否有任何命令可以查看/proc中文件的实际大小?

i know this is not a file on disk, but a file in the memory, so is there any command which i can see the real size of the files in /proc?

root@OpenWrt:/proc/sys/net/ipv4# cat ip_forward | wc -c
2
root@OpenWrt:/proc/sys/net/ipv4# ls -l ip_forward
-rw-r--r--    1 root     root            0 Sep  3 00:20 ip_forward
root@OpenWrt:/proc/sys/net/ipv4# pwd
/proc/sys/net/ipv4 

推荐答案

那些实际上不是磁盘上的文件(正如您提到的),但它们也不是内存中的文件 -/proc 中的名称对应于对正在运行的内核的调用在操作系统中,内容是即时生成的.

Those are not really files on disk (as you mention) but they are also not files in memory - the names in /proc correspond to calls into the running kernel in the operating system, and the contents are generated on the fly.

如果不生成文件,系统不知道文件有多大,但如果您读取文件"两次,则无法保证您获得相同的数据,因为系统可能已更改.

The system doesn't know how large the files would be without generating them, but if you read the "file" twice there's no guarantee you get the same data because the system may have changed.

您可能正在寻找该程序sysctl -a相反.

You might be looking for the program sysctl -a instead.

这篇关于如何显示/proc中文件的大小?它不应该是零尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆