#!/bin/bash
cat $1 | ./words_num word | cat $1
单词数
#!/bin/bash
while read line; do
temp=`echo $line | grep $1 | wc -l`
if (($temp==1)); then
word_cnt=`echo $line | wc -w`
echo "$line $word_cnt"
else
echo "$line"
fi
done
例如,在文件之前:
bla bla blaa word
words blaa
bla bla
文件后:
bla bla blaa word 4
words blaa 2
bla bla
Can you help?