【问题标题】:'<' operator in terminal command line终端命令行中的“<”运算符
【发布时间】:2016-02-10 14:44:18
【问题描述】:

cat &lt; test.txt 与普通cat test.txt 相比表现是否不同?

据我了解

【问题讨论】:

    标签: macos unix command-line terminal


    【解决方案1】:

    使用cat file.txt,打开和读取文件的系统调用由cat 发出,而在cat &lt; file.txt 中,这些调用由shell 发出,然后shell 通过标准输入将文件的内容传送到cat .最终结果是一样的,据我所知没有其他区别。

    【讨论】:

    • 解释清楚。谢谢 ; )
    • 好答案。我可以看到它有所不同的唯一情况是,如果file.txt 不能被当前 shell 打开(因为当前用户没有所需的权限)并且cat 正在以超级用户权限运行sudo.
    猜你喜欢
    • 2019-12-22
    • 1970-01-01
    • 1970-01-01
    • 2018-12-28
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-12
    相关资源
    最近更新 更多