如何将wc的标准输出写入文件?

问题描述 投票:0回答:3

下面的命令将显示当前目录中每个文件中包含多少个字符。

find  -name '*.*' |xargs  wc -c  

我想将杰出表现写入文件。

find  -name '*.*' |xargs  wc -c  > /tmp/record.txt

遇到问题:

wc: .: Is a directory

如何将所有标准输出写入文件?

bash stdout xargs
3个回答
0
投票

我想您可能是说find |xargs wc -c

find -name '.'仅返回.


0
投票

仅过滤文件,如果只需要文件。

find -type f

0
投票

为什么-name '*.*'?那将不会找到每个文件,而是会找到目录。您需要使用-type f,并且比使用xargs更好地将结果传递到-exec

find . -type f -maxdepth 1 -exec wc -c {} + > /tmp/record.txt

-maxdepth 1保证搜索不会在子目录中进行。

© www.soinside.com 2019 - 2024. All rights reserved.