有没有办法获得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变量中给出的bash回显文件行数
想知道如何将文本文件中的行数输出到屏幕,然后将其存储在变量中.我有一个名为stats.txt的文件,当我运行wc -l stats.txt它时输出8 stats.txt
我试过x = wc -l stats.txt认为它只存储数字,其余只是为了视觉,但它不起作用:(
谢谢您的帮助