How do I get filename and line count per file using powershell -


i have following powershell script count lines per file in given directory:

dir -include *.csv -recurse | foreach{get-content $_ | measure-object -line} 

this giving me following output:

lines    words    characters    property -----    -----    ----------    --------    27    90    11    95   449   ... 

the counts-per-file fine (i don't require words, characters, or property), don't know filename count for.

the ideal output like:

filename        lines --------        ----- filename1.txt      27 filename1.txt      90 filename1.txt      11 filename1.txt      95 filename1.txt     449   ... 

how add filename output?

try this:

dir -include *.csv -recurse |     % { $_ | select name, @{n="lines";e={        get-content $_ |           measure-object -line |              select -expa lines }                                        }       } | ft -autosize 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -