[英]How do I run a terminal command at the same time as executing a C program from terminal
I have a C program executable. 我有一个C程序可执行文件。 I will run a terminal command at the same time as I run the program and wonder how I would do that?
我将在运行程序的同时运行终端命令,并且想知道我该怎么做?
./program | ps -l -u ${USER} | grep info
I put in my username for USER but I get: 我输入了USER的用户名,但得到了:
Usage: ps [options]
用法:ps [选项]
Try 'ps --help ' or 'ps --help ' for additional help text.
尝试使用“ ps --help”或“ ps --help”以获取其他帮助文本。
For more details see ps(1).
有关更多详细信息,请参见ps(1)。
Don't know what I do wrong? 不知道我做错了什么?
如标题中所述回答您要运行的问题
./program & ps ...
You probably want to run your ./program
in the background as you grep
the output from ps
: 您可能要在
grep
ps
的输出时在后台运行./program
:
./program & ps -l -u ${USER} | grep info
the &
puts ./program
in the background where as |
&
将./program
放在后台,其中|
is used to pipe the output of one command to another 用于将一个命令的输出传递给另一个命令
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.