Oneliner to count the number of tabs in each line of a file

Posted by JasonHorner on Stack Overflow See other posts from Stack Overflow or by JasonHorner
Published on 2009-08-11T21:46:36Z Indexed on 2010/05/04 0:48 UTC
Read the original article Hit count: 234

Filed under:
|

I have a file that is tab delimited. I would like a powershell script that counts the number of tabs in each line. I came up with this:

${C:\tabfile.txt} |% {$_} | Select-String \t | Measure-Object | fl count

it yields 3, Which is the number of lines in the file.

any pointers to what I'm doing wrong? I would like it to print a single number for each line in the file.

© Stack Overflow or respective owner

Related posts about powershell

Related posts about one-liner