Skip to content
Advertisement

How to count number of tabs in each line using shell script?

I need to write a script to count the number of tabs in each line of a file and print the output to a text file (e.g., output.txt).

How do I do this?

Advertisement

Answer

awk '{print gsub(/t/,"")}' inputfile > output.txt
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement