简体   繁体   English

将命令的输出重定向到/ proc

[英]redirecting an output of command to /proc

I have created a kernel module to have a proc file into which I can read and write data. 我创建了一个内核模块,以拥有一个proc文件,我可以在其中读取和写入数据。 After using insmod mymodule.ko , I am able to write simple text into my proc file as: 使用insmod mymodule.ko ,我可以将简单文本写入proc文件中,如下所示:

echo "Hello world" > /proc/myprocfile

I am also able to read data from my proc file properly using: 我还可以使用以下方法从proc文件中正确读取数据:

cat /proc/myprocfile

My question is if I want to write the contents of a command say, ls /proc rather than simply echoing a message, then how to send the output of such command to myprocfile . 我的问题是,如果我想编写命令的内容,例如ls /proc而不是简单地回显一条消息,那么如何将此类命令的输出发送到myprocfile

ls /proc > /proc/myprocfile

由于这似乎是您要找的内容,因此这里是IO重定向的Wikipedia页面,其中提供了更多示例并解释了其他一些IO重​​定向操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM