【问题标题】:What does the following command do ls -la | sort | wc -l下面的命令是做什么的 ls -la |排序 | wc -l
【发布时间】:2017-05-08 22:20:47
【问题描述】:

当我在终端中运行此命令时,它会显示一个数字。 当我使用 cd 命令挂载另一个文件夹时,数字会发生变化。

【问题讨论】:

  • 感谢您的帮助!
  • explainshell 救援!
  • 一次执行 cmd。 ls -la(在一个小目录中)有什么作用?现在添加|sort 它发生了怎样的变化。现在添加|wc -l 哦.. 方式不同吧?组合 cmd 链并分解它们(用于调试)是 Unix/Linux shell 脚本的主要关键(和美感)。做好一件事,可以用管道连接在一起的小程序(|)。祝你好运。

标签: linux ubuntu


【解决方案1】:
ls -la // List files in your current directory (hidden files are included thanks to the -a)

sort // Sort entries returned by the previous command

wc -l // Returns the number of lines returned by the previous command

«|»将一个命令的输出发送到下一个命令的输入

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-01
    • 2015-03-30
    • 1970-01-01
    • 1970-01-01
    • 2017-07-26
    • 2020-05-10
    • 2016-11-15
    • 2014-10-10
    相关资源
    最近更新 更多