如何使用powershell(1.0)读取文本文件中的最后一个字? [英] How to read last word in text file using powershell(1.0)?

查看:29
本文介绍了如何使用powershell(1.0)读取文本文件中的最后一个字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本文件内容,如下所示,

I've a text file content like below,

     123    123   123   123   123   Exchange

<小时>

我想要最后一个词Exchange",需要在 powershell 中解决.请帮帮我.


i want that last word "Exchange", need solution in powershell. please help me.

注意:文件开头是TAB,字符之间也是.

Note: beginning of the file is TAB, also between the Character.

谢谢,内存

推荐答案

拆分行,如果存在则删除空条目,并获取最后一个元素:

Split the line, remove empty entries if exist, and get the last element:

$content= Get-Content file.txt
$content.Split("`t",[System.StringSplitOptions]::RemoveEmptyEntries)[-1]

这篇关于如何使用powershell(1.0)读取文本文件中的最后一个字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆