Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

multipe search criteria in vi

I have a vi editor

Q1 I need to search text in a large file for multiple criteria like

date should be 03/23/2011 and text should be abc

:? 03/23/2011 abc

Q2. I want to search for last occurance of word abc in the vi editor
0
gram77
Asked:
gram77
  • 3
  • 2
2 Solutions
 
farzanjCommented:
Q1:
In the command mode:
Enter the following
:/\03\/23\/2011 abc


Q2:
In the command mode
G
:?abc
0
 
gram77Author Commented:
/\03\/23\/2011 abc does not work
0
 
farzanjCommented:
I am sorry, I mistyped it

/03\/23\/2011 abc

If that doesn't work

Try
/03\/23\/2011.*abc

Also try
/03.23.2011.*abc


All of the above should work
0
 
farzanjCommented:
For question 1:
If you are at the top of the file  (if not you can do 'gg'), or at the bottom of the file (or you can go to the bottom by pressing G)you can do

:?abc
0
 
gram77Author Commented:
excellent
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now