如何使用 PowerShell 打印文件的某一行? [英] How to print a certain line of a file with PowerShell?

查看:84
本文介绍了如何使用 PowerShell 打印文件的某一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这台服务器上没有像样的文本编辑器,但我需要看看是什么导致了某个文件的第 10 行出现错误.不过我确实有 PowerShell...

I don't have a decent text editor on this server, but I need to see what's causing an error on line 10 of a certain file. I do have PowerShell though...

推荐答案

这将显示 myfile.txt 的第 10 行:

This will show the 10th line of myfile.txt:

get-content myfile.txt |选择 -first 1 -skip 9

-first-skip 都是可选参数,-context-last 可以是在类似情况下很有用.

both -first and -skip are optional parameters, and -context, or -last may be useful in similar situations.

这篇关于如何使用 PowerShell 打印文件的某一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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