By MBPDLPayday Loans

删除文本文件开头的几行

今天遇到一个问题, 我需要用程序来分析nbtscanner产生的report文件, 可惜这个文件格式有点小问题 — 前3行加了些杂七杂八的注释, 解决的办法要么我在程序分析的时候skip前三行, 可惜C#的StreamReader弄起来有点罗嗦,要先读, 然后skip, 难道就不能直接指定起始行吗? 哪位兄弟知道的话请comments我… 嘿嘿

后来在DRL上看到hitme的一个方法 — more.

这是一个dos命令, /? 查了一下帮助:

MORE [/E [/C] [/P] [/S] [/Tn] [+n]] < [drive:][path]filename
command-name | MORE [/E [/C] [/P] [/S] [/Tn] [+n]]
MORE /E [/C] [/P] [/S] [/Tn] [+n] [files]

[drive:][path]filename  Specifies a file to display one
screen at a time.

command-name            Specifies a command whose output
will be displayed.

/E      Enable extended features
/C      Clear screen before displaying page
/P      Expand FormFeed characters
/S      Squeeze multiple blank lines into a single line
/Tn     Expand tabs to n spaces (default 8)

Switches can be present in the MORE environment
variable.

+n      Start displaying the first file at line n

files   List of files to be displayed. Files in the list
are separated by blanks.

If extended features are enabled, the following commands
are accepted at the — More — prompt:

P n     Display next n lines
S n     Skip next n lines
F       Display next file
Q       Quit
=       Show line number
?       Show help line
<space> Display next page
<ret>   Display next line

简单的说,比如要去掉某个txt文件的前3行: more +3 in.txt>out.txt

Leave a Reply