相关疑难解决方法(0)

从bash中获取wc中的整数

有没有办法获得wc在bash中返回的整数?

基本上我想在文件名之后将行号和字数写入屏幕.

output: filename linecount wordcount 这是我到目前为止:

files=`ls`
for f in $files;
do
        if [ ! -d $f ] #only print out information about files !directories
        then
                # some way of getting the wc integers into shell variables and then printing them
                echo "$f $lines $ words"
        fi
done

bash wc

110
推荐指数
7
解决办法
8万
查看次数

输出要在Unix中屏幕显示的文本文件中的行数

可能重复:
bash变量中给出的bash回显文件行数

想知道如何将文本文件中的行数输出到屏幕,然后将其存储在变量中.我有一个名为stats.txt的文件,当我运行wc -l stats.txt它时输出8 stats.txt

我试过x = wc -l stats.txt认为它只存储数字,其余只是为了视觉,但它不起作用:(

谢谢您的帮助

unix bash

9
推荐指数
2
解决办法
3万
查看次数

标签 统计

bash ×2

unix ×1

wc ×1