Reputation: 27
I am using gVim 7.4.68 on Windows 7. I have a text file which is has the content as shown below. The two entries given below are for example only. The text file has 100s of such fields that have the Pseudo Name, Symmetrix ID, Logical Device, State/policy, and the path related information.
Pseudo name=emcpowermg
Symmetrix ID=000123456781234
Logical device ID=01D3
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats ---
### HW Path I/O Paths Interf. Mode State Q-IOs Errors
==============================================================================
1 qla2xxx sdga FA 10bA active alive 0 1
0 qla2xxx sdgb FA 7bA active alive 0 0
Pseudo name=emcpowerdl
Symmetrix ID=000123456780000
Logical device ID=0427
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats ---
### HW Path I/O Paths Interf. Mode State Q-IOs Errors
==============================================================================
1 qla2xxx sdaca FA 9bA active alive 0 0
0 qla2xxx sdaci FA 8bA active alive 0 0
I just want to filter out everything else except The Symmetrix ID and the Logical Device so that, the entire file is filled with entries such as:
Symmetrix ID=000123456781234
Logical device ID=01D3
Symmetrix ID=000123456780000
Logical device ID=042
Tried:
%v/^Symmetrix.*\nLogical/d
and
%v/^Symmetrix.*\rLogical/d
Then tried copy pasting the stuff so that the ^M would appear correctly:
%v/^Symmetrix.*^M^Logical/d
But none of this works. It does not filter anything and I get a blank screen. Kindly let me know where I am going wrong.
I recently started using gVim and am still getting a hang of it.
Regards, pmu
Upvotes: 0
Views: 101
Reputation: 196751
This command works with the given sample:
:v/^\(Symmetrix\|Logical\)/d
We look for lines that don't start with either Symmetrix
or Logical
and we d
elete them.
The same command with less backslashes thanks to \v
erymagic:
:v/^\v(Symmetrix|Logical)/d
(edit)
The main reason behind the failing of your attempts is that you actually match the Symmetrix
line but not the Logical
line, even if you introduced a \nLogical
in your pattern: when the pattern spans multiple lines, the actual matched line is the first line, not the two lines you targeted in your pattern.
Upvotes: 4