获取文本文档中每一行的字符数 [英] Getting character count for each row in text doc
问题描述
我正在尝试获取文本文档中每一行的字符数.我的文本文档的内容是:
I am trying to get the character count for each row in a text doc. The contents of my text doc are:
1
15
69
124
300
我一直在尝试 PS 脚本的变体:
I've been trying variants of the PS script:
get-content c:\serverlist.txt | foreach-object {measure-object -character}
但我能得到的最好回报是:
But the best I can get returned is:
行 单词 字符 属性
------- -------- -------------- -----------
0
0
0
nbsp; 0
0
Lines Words Characters Property
------- -------- -------------- -----------
0
0
0
0
0
不确定我在这里遗漏了什么,但任何帮助将不胜感激!
Not sure what I'm missing here, but any help would be appreciated!
谢谢!
推荐答案
你必须直接进入Measure-Object
:
Get-Content c:\serverlist.txt | Measure-Object -Character
否则你必须做任何一个
| ForEach-Object { $_ | Measure-Object -Character }
这会有点奇怪地使用管道或
which would be a bit of weird use of the pipeline or
| ForEach-Object { Measure-Object -Character -InputObject $_ }
这与上面的变体几乎相同.
which would be just about the same as the variant above.
这篇关于获取文本文档中每一行的字符数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!