How to count number of words from String using shell

后端 未结 6 1558
梦谈多话
梦谈多话 2020-12-16 09:44

I want to count number of words from a String using Shell.

Suppose the String is:

input=\"Count from this String\"

Here the delimit

6条回答
  •  感情败类
    2020-12-16 10:22

    I'll just chime in with a perl one-liner (avoiding 'useless use of echo'):

    perl -lane 'print scalar(@F)' <<< $input
    

提交回复
热议问题