0

假设我有一个文件名 Trialcr.txt

PAR875:FXOV003506A_02> typ trialcr.txt

Classes in CMS Library DISK_FXOCMS:[fxo.CMS.LIBS.FXO_LIV.SRC]

FXO_CR012123 "FXO_CR1232 : FXOME-sfsfsfsf dasdad "
    ABC.COM 2
    PQ.BSQL 1

我想删除前 4 行并只保留

ABC.com 和 PQ.com

希望这是动态完成的。

任何人都可以建议吗

4

3 回答 3

2

我喜欢使用 PERL 或 AWK 来完成这类任务。

$ perl -ne "print if $. > 4" TRIALCR.TXT  [ > x.x ]
$
$ gawk /com="NR>4" TRIALCR.TXT  [/output=x.x]

根据 user2116290 搜索已知存在的字符串也可以。对于最近的 OpenVMS 版本,对于这种特定情况,请考虑在不存在的字符串上搜索不匹配项并跳过 4 行。(搜索“”不匹配空行)

$ search TRIALCR.TXT;1 "@#$%" /match=nor /skip=4

吉姆在他的剧本中有一个很好的答案。如果您了解进程永久文件的工作方式,则可以进行很好的简化。让 DCL 吞下前 4 行,然后将其余行复制到目标文件。

$ close/nolog input
$ open/read/error=error input trialcr.txt
$ read/end=error/error=error input junk
$ read/end=error/error=error input junk
$ read/end=error/error=error input junk
$ read/end=error/error=error input junk
$ COPY input trialcr.txt
$ close input
$exit:
$ exit
$error:
$ write sys$output "Unexpected error: " + f$message ($status)
$ goto exit

享受,海​​因

于 2013-10-08T11:37:29.223 回答
2
$ close/nolog input
$ close/nolog temp
$ temp = f$unique () + ".tmp"
$ open/read/error=error input trialcr.txt
$ open/write/error=error temp 'temp'
$ read/end=error/error=error input junk
$ read/end=error/error=error input junk
$ read/end=error/error=error input junk
$ read/end=error/error=error input junk
$loop:
$ read/end=end_loop/error=error input record
$ write/error=error temp record
$ goto loop
$end_loop:
$ close input
$ close temp
$ rename 'temp' trialcr.txt
$ goto exit
$error:
$ write sys$output "Unexpected error: " + f$message ($status)
$ goto exit
$exit:
$ exit
于 2013-10-04T20:12:41.687 回答
0

假设我有一个文件名 Trialcr.txt

这看起来像是 FXO_CR012123 类的 CMS SHOW CLASS/CONTENT 的输出。在您的示例中,给定这样一个命令的输出布局(元素名称前面有四个空格),一个简单的

$ search Trialcr.txt "    "

应该打印想要的行。但是,一般来说,类名和它的描述之间可能有多达四个空格。为了安全起见,像

$ pipe search Trialcr.txt "    " |search sys$pipe FXO_CR012123/match=nand

应该为所有类名产生预期的结果。重定向输出会将所需的行(包括版本号)写入文件。

于 2013-10-07T16:07:04.687 回答