c - shell 如何处理重定向

标签 c shell

我必须用 C 语言编写自己的 shell,目前我正在处理 > < >> <<运营商。我处理| (管道)但我无法理解分割线路的所有优先级。

对于像 ls -la | cat -e ; ps 这样的东西我会做ls -la | cat -e然后是 ps ,没什么难的。

随着重定向< > << >>运算符的优先顺序是什么?

最佳答案

shell 按照重定向操作符出现的顺序(或者从命令的开始到结束,从左到右)处理重定向操作符。

此行为是specified by POSIX :

If more than one redirection operator is specified with a command, the order of evaluation is from beginning to end.

关于c - shell 如何处理重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33906577/

相关文章:

c - 数据包复制的影响

javascript - If Else VS 多个 If 语句

linux - 如何在 sh 文件中并行运行 shell 脚本命令?

python如何在linux shell中使用子进程管道

linux - 查找所有没有损坏链接的文件

php - 有没有办法在不等待命令完成的情况下使用 shell_exec ?

android - 如何为 Android 创建电视调谐器库?

c - 这段代码如何在不使用 sizeof( ) 的情况下确定数组大小?

C 程序 - 指针数组乘法

shell - Unix shell 中的特殊变量?