vim command for a search


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting vim command for a search
# 1  
Old 11-04-2012
vim command for a search

how can i search each line for ROCT and ROCT1.ROCT1 will be always 1 line after ROCT.
Both the patterns will be found at the end of the line (in alternate lines)

<pattern file>
(rising edge-triggered flip-flop clocked by ROCT)

Endpoint: U_UFSMPHYCOREV10/U_UFSMPHYV10_DIGITAL/U_umr_top/U_sym_align
(rising edge-triggered flip-flop clocked by ROCT1)

---------- Post updated at 08:02 PM ---------- Previous update was at 01:36 PM ----------

Quote:
Originally Posted by dll_fpga
how can i search each line for ROCT and ROCT1.ROCT1 will be always 1 line after ROCT.
Both the patterns will be found at the end of the line (in alternate lines)

<pattern file>
(rising edge-triggered flip-flop clocked by ROCT)

Endpoint: U_UFSMPHYCOREV10/U_UFSMPHYV10_DIGITAL/U_umr_top/U_sym_align
(rising edge-triggered flip-flop clocked by ROCT1)
---------- Post updated at 08:07 PM ---------- Previous update was at 08:02 PM ----------

This is the command i tried but didnt work

/ROCT .* /n ROCT1

---------- Post updated at 08:13 PM ---------- Previous update was at 08:07 PM ----------

Kindly please help..
# 2  
Old 11-04-2012
What do you want to do with those lines after you find them?

The vim (or actually ex) command :g/ROCT/.,/ROCT1/p will print the line containing ROCT through the next line containing ROCT1 for each line that contains ROCT.
# 3  
Old 11-04-2012
or you can just grep the file:

Code:
grep Roct $FILENAME

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell vim defaulting to Insert or Command mode

On a daily basis I need to SSH into several different RHEL servers using Putty. On some of the servers, if I up arrow to get a previous command, it automatically starts in Input Mode, so if I press up arrow, then 'x' it will type the letter x at the end of the command line. On other servers, it... (4 Replies)
Discussion started by: derndingle
4 Replies

2. OS X (Apple)

Diff between vim and macvim ( command \ll )

Hello all! I am quite a newbie in vim. In MacVim the command \ll (That means \ + L + L) compiles my LaTeX file, which I am just editing, with the command pdflatex (coming out is a .pdf file) - But in my Shell-vim with only the command latex (coming out is a .dvi file). Supplemental... (0 Replies)
Discussion started by: marek
0 Replies

3. Shell Programming and Scripting

Vi / vim - Insert a external command response

I would like to execute and external command and insert it into a particular area of the file I am editing. Note that I have the ORIGINAL AT&T vi training doc dated 1987. Doesnt explain it. As an example, in a vi editor I have I would like the result : After executing the following... (1 Reply)
Discussion started by: popeye
1 Replies

4. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

5. UNIX for Dummies Questions & Answers

VIM search and replace with line breaks in both the target and replacement text

Hi, Ive spent ages trying to find an explanation for how to do this on the web, but now feel like I'm :wall: I would like to change each occurence (there are many within my script) of the following: to in Vim. I know how to search and replace when it is just single lines... (2 Replies)
Discussion started by: blueade7
2 Replies

6. UNIX for Dummies Questions & Answers

Vim external command output to new buffer

Hi, From inside Vim, I'm looking for a way to use the contents of the current buffer, pass it to an external executable, and then return the output from the executable into a new Vim buffer. I know that I can do something like %!<executable>, but that will overwrite the contents of the... (3 Replies)
Discussion started by: konfushus
3 Replies

7. Solaris

Very Importan - Vim Settings - Error while opening a File using vim

I downloaded vim.7.2 and compiled the vim source . Added the vim binary path to PATH (Because iam not the root of the box) when i load the file using vim it throws me an error Error detected while processing /home2/e3003091/.vimrc: line 2: E185: Cannot find color scheme darkblue line... (0 Replies)
Discussion started by: girija
0 Replies

8. Solaris

passwd command search

Hi. When i execute which passwdit is showing /usr/bin/passwd, eventhough i set my path as PATH=/etc:$PATH i just checked the permission for the passwd under /usr/bin -r-sr-sr-x what exactly happening? and what is that s signifies Thanks. (5 Replies)
Discussion started by: shahnazurs
5 Replies

9. UNIX for Dummies Questions & Answers

vim as command line editor

Here is my problem, I manage a SunOs 5.8 Server, vi is the default command line editor, I have a line on each users .kshrc profile as follows: export EDITOR=/bin/vi I want to use vim as the command line editor, the below line doesn't work export EDITOR=/bin/vim Thank you (1 Reply)
Discussion started by: tony3101
1 Replies

10. UNIX for Dummies Questions & Answers

In Search of a Command

Hello, There is a command out there that gives back info on your system; e.g. PentiumIII, etc. I came across it a while back, but cannot find it now. Does anyone know what that command is? Thanks, Radimus (2 Replies)
Discussion started by: radimus
2 Replies
Login or Register to Ask a Question