linux - 这可以打印在同一行吗?

标签 linux bash

此命令将计算子目录中的文件数量。

find . -maxdepth 1 -type d |while read dir;do echo "$dir";find "$dir" -type f|wc -l;done

看起来像

./lib64
327
./bin
118

是否可以让它看起来像

327 ./lib64
118 ./bin

相反?

最佳答案

有很多方法可以做到这一点......这里有一些不会对您的代码进行太大更改的方法。 (为了便于阅读,我将其分成多行。)

find . -maxdepth 1 -type d | while read dir; do
   echo `find "$dir" -type f | wc -l` "$dir"
done

关于linux - 这可以打印在同一行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6012296/

相关文章:

linux - 'stat' 是否会由于实际刷新缓存而对大量文件造成性能影响?

linux - 为什么从 https 服务器下载文件在带有 montavista linux 的嵌入式设备上不起作用?

linux - sed 命令插入文本 - bash

linux - 比较 Bash 中按字母顺序排列的字符串、测试与双括号语法

linux - 在 Bash 中计算平均值

linux - boto 中的用户数据脚本没有被执行

c# - 无法在解决方案中构建某些项目?

linux - 如何 grep 查找文件中的特定模式

python - 从 bash 脚本向 python 解释器传递参数

linux - 如何在bash中逐列组合两个变量