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 - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -