Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Hi i have used this code snippet to input a file and count the number of tabs in each line and print the result to output file, but i m getting the error

awk: cmd. line:1: Unexpected token

What could be the mistake

#!/bin/sh
FILE='unit-1-slide.txt'
OUTPUTFILE='output-for'-$FILE
COUNT=$(awk '{print gsub(/\t/,"")}'$FILE)
OUTPUT_PATH='/home/user/Desktop'
echo $COUNT > $OUTPUTFILE
echo "Done!"
                By convention all-upper-case variable names are reserved for exported variables. Also, always quote your variables (e.g. "$FILE" instead of $FILE) to avoid undesirable consequences of filename expansion, etc. Finally, the awk command could be written more clearly as awk -F'\t' '{print NF}'.
– Ed Morton
                Mar 20, 2013 at 12:43
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.