- 论坛徽章:
- 0
|
本帖最后由 sonorous 于 2012-03-20 11:42 编辑
如何按条件从文件中提取内容,然后拼到另一文件中:
file1内容如下:
INVISIBLE File System backup02 (Saveset 14) 10:57 20 Mar 2012
INVISIBLE File System backup05 (Saveset 13) 10:57 20 Mar 2012
INVISIBLE File System backup03 (Saveset 12) 10:57 20 Mar 2012
INVISIBLE File System backup05 (Saveset 11) 10:57 20 Mar 2012
INVISIBLE File System backup04 (Saveset 10) 10:57 20 Mar 2012
file2内容如下:
35 ------------Workstation INVISIBLE Report
N/A---------
36 ------------Workstation INVISIBLE Report
N/A---------
37 ------------Workstation INVISIBLE Report
N/A---------
38 ------------Disk StorageINVISIBLE Report
N/A---------
39 None backup01 INVISIBLE Backup
Include: INVISIBLE->File System->Fixed Drives->C:\->debug.log
Include: INVISIBLE->File System->Fixed Drives->C:\->CONFIG.SYS
Include: INVISIBLE->File System->Fixed Drives->C:\->AUTOEXEC.BAT
Include: INVISIBLE->File System->Fixed Drives->C:\->Kugou
Include: INVISIBLE->File System->Fixed Drives->C:\->IDE
---------
40 None backup02 INVISIBLE Backup
Include: INVISIBLE->File System->Fixed Drives->C:\->CONFIG.SYS
Include: INVISIBLE->File System->Fixed Drives->C:\->AUTOEXEC.BAT
Include: INVISIBLE->File System->Fixed Drives->C:\->Kugou
Include: INVISIBLE->File System->Fixed Drives->C:\->IDE
20 yrs
41 rst-backup01rst-backup01INVISIBLE Restore
Include: INVISIBLE->File System->backup01 (Saveset 6) 20:42 19 Mar 2012->C:\
---------
42 rst-backup02rst-backup02INVISIBLE Restore
Include: INVISIBLE->File System->backup02 (Saveset 5) 20:42 19 Mar 2012->C:\
提取file2中的Include中的C:\合并到file1中,在file1中增加一列,最终file1的内容显示如下:
INVISIBLE File System backup02 (Saveset 14) 10:57 20 Mar 2012 C:\
INVISIBLE File System backup05 (Saveset 13) 10:57 20 Mar 2012 D:\
INVISIBLE File System backup03 (Saveset 12) 10:57 20 Mar 2012 /home
INVISIBLE File System backup05 (Saveset 11) 10:57 20 Mar 2012 E:\
INVISIBLE File System backup04 (Saveset 10) 10:57 20 Mar 2012 /usr
筛选条件:
1.file1中的第4列名字与file2中的名字匹配
file1: INVISIBLE File System backup02 (Saveset 14) 10:57 20 Mar 2012 C:\
file2: 40 None backup02 INVISIBLE Backup
2.file1中的第1旬名字与file2中的名字匹配
file1: INVISIBLE File System backup02 (Saveset 14) 10:57 20 Mar 2012 C:\
file2: 40 None backup02 INVISIBLE Backup
3.读取file2中的Include内容,取“Fixed Drives“后的第一个值,如”C:\“,"D:\",假如是UNIX,那么应该是“/”,Include可能有多行,行数不固定,如果都是”C:\“开头,只要取一个即可,如果有C:\, D:\,那么各取一
4.合并到file1对应行的最后一列
5.补充一下,刚才忘了一点,只取backup类型的,且保存5year以上的,restore的忽略
40 None backup02 INVISIBLE Backup
Include: INVISIBLE->File System->Fixed Drives->C:\->CONFIG.SYS
Include: INVISIBLE->File System->Fixed Drives->C:\->AUTOEXEC.BAT
Include: INVISIBLE->File System->Fixed Drives->C:\->Kugou
Include: INVISIBLE->File System->Fixed Drives->C:\->IDE
20 yrs
|
|