0

I wrote a code to count the number of word per line. Here is my code

num= $(echo $compareFile1 | wc -w)

Here $compareFile1 contains each line. I am trying to get the number in num variable. But I am getting the following error

line 3: 6: command not found

where 6 clearly the number of word. I checked. but there is nothing in the num variable and also the error. Anybody can help me?

sovon
  • 877
  • 2
  • 12
  • 28

1 Answers1

1

there should not be space after the = operator, that is: num=$(echo $compareFile1 | wc -w)

lutaoact
  • 4,149
  • 6
  • 29
  • 41