how to count all words that ended with ".wsp" in the file

more file

meanwhile, I create this syntax

 sed s'/\// / g' file   | awk '{print $NF}' | grep -o '.wsp' | wc -l

but this syntax isn't so elegant

  • I mean to count the words .wsp that ended on each line ( only if they ended ) – yael Aug 30 '18 at 17:05
  • I want to count only the ".wsp" words that ended in the line , if ".wsp" not ended in the line then no need to count it – yael Aug 30 '18 at 17:12
  • 3
    The title should have been the reverse: "Count the lines that ended in a specific word".... – Rakesh Sharma Aug 30 '18 at 18:58

Try this,

 grep -c '\.wsp$' file
  • -c count of matching lines for each input file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.