Questions tagged «wc»


14
在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
115 bash  wc 

6
bash回显bash变量中给出的文件行数,不带文件名
我在bash脚本中具有以下三个构造: NUMOFLINES=$(wc -l $JAVA_TAGS_FILE) echo $NUMOFLINES" lines" echo $(wc -l $JAVA_TAGS_FILE)" lines" echo "$(wc -l $JAVA_TAGS_FILE) lines" 运行脚本时,它们都产生相同的输出: 121711 /home/slash/.java_base.tag lines 121711 /home/slash/.java_base.tag lines 121711 /home/slash/.java_base.tag lines 即文件名也被回显(我不想)。为什么这些Scriplet失败,我应该如何输出干净的消息: 121711 lines ?
79 bash  wc 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.