Help to find two pattern in vi editor


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help to find two pattern in vi editor
# 1  
Old 04-24-2014
Help to find two pattern in vi editor

I want to find two pattern in vi editor.for example in file demo.txt
I want to find a record such as "BDBO" and "sh".
how can i find such a record bu using single command in demo.txt in vi editor.
please help.

---------- Post updated at 01:49 AM ---------- Previous update was at 01:46 AM ----------

currently am searching by using /BDBO and than /sh.help me to find both pattern by using single command or script.
Thanks.
# 2  
Old 04-24-2014
Code:
Esc
/BDBO\|sh

# 3  
Old 04-24-2014
The vi utility is not intended for use in scripts. What do you intend to do once you have found BDBO and sh.help?

Are you looking for BDBO before sh.help on the same line in a file? Are you looking for both on the same line in any order? Are you looking for sh.help on a line in the file after a line that contains BDBO?

What do you want to happen if there is more than one occurrence of these strings in a file?
# 4  
Old 04-24-2014
first i want to find "BDBO" than "sh" in a same file.

---------- Post updated at 02:25 AM ---------- Previous update was at 02:19 AM ----------

its not working i want to find record which contain both pattern. BDBoO and sh

---------- Post updated at 02:27 AM ---------- Previous update was at 02:25 AM ----------

first i want to find "BDBO" than "sh" in a same file.
its not working i want to find record which contain both pattern. BDBoO and sh

---------- Post updated at 02:29 AM ---------- Previous update was at 02:27 AM ----------

its ok if multi occurance
# 5  
Old 04-24-2014
So you find BDBO and then you find sh (or sh.help). Then what do you want to do?

After you have found BDBO, does sh have to be on the same line? On a later line in the file? On an earlier line in the file?

Most people use an editor to make changes to a file; not just search for two strings? What are you trying to do?

What constitutes a record? Is a line a record? Does sh have to come after BDBO in a record?
# 6  
Old 04-24-2014
yes its record of string e.g BDBO;Isn10002;CurEUR;s4;MSi;sh.....
there are thousands of record in a file.i have to find such record which contain BDBO and sh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find a pattern and traverse left and pick something from another pattern

I have a Text like below , Detailed Table Information Table(tableName:a1, dbName:default, owner:eedc_hdp_s_d-itm-e, createTime:1520514151, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:, location:hdfs://DBDP-Dev/apps/hive/warehouse/a1,... (6 Replies)
Discussion started by: nv186000
6 Replies

2. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

3. Shell Programming and Scripting

Vi editor deleting lines with specific pattern

Hi, I need to delete all lines in the file using vi editor which start with word aternqaco. Please assist. aternqaco.__oracle_base='/amdbqa01/app/oracle'#ORACLE_BASE set from environment aternqa.__oracle_base='/amdbqa01/app/oracle'#ORACLE_BASE set from environment... (3 Replies)
Discussion started by: Vishal_dba
3 Replies

4. UNIX for Dummies Questions & Answers

Find pattern suffix matching pattern

Hi, I am trying to get a result out of this but fails please help. Have two files /tmp/1 & /tmp/hosts. /tmp/1 IP=123.456.789.01 WAS_HOSTNAME=abcdefgh.was.tb.dsdc /tmp/hosts 123.456.789.01 I want this result in /tmp/hosts if hostname is already there dont want duplicate entry. ... (5 Replies)
Discussion started by: rajeshwebspere
5 Replies

5. Shell Programming and Scripting

How to find a file with a specific pattern for current sysdate & upon find email the details?

I need assistance with following requirement, I am new to Unix. I want to do the following task but stuck with file creation date(sysdate) Following is the requirement I need to create a script that will read the abc/xyz/klm folder and look for *.err files for that day’s date and then send an... (4 Replies)
Discussion started by: PreetArul
4 Replies

6. UNIX for Dummies Questions & Answers

Find next line based on pattern, if it is similar pattern skip it

Hi, I am able to get next line if it is matching a particular pattern. But i need a way to skip if next line also matches same pattern.. For example: No Records No Records Records found got it Records found Now i want to find 'Records found' after 'No Records' pattern matches.. ... (5 Replies)
Discussion started by: nagpa531
5 Replies

7. UNIX for Advanced & Expert Users

Need pattern matching in vi editor

Hi, I want to remove all the digits/characters after the last underscore in the following set of lines abc_cdef_12_456_98765 defs_qw_4567_23_0877_89976769870 deffon_asdcdc_23_980980_098 sdfre_rtt_grt the result im expecting is abc_cdef_12_456 defs_qw_4567_23_0877 deffon_asdcdc_23... (3 Replies)
Discussion started by: appualex
3 Replies

8. Shell Programming and Scripting

Find and replace pattern in VI editor

All, I have a text file which has the following data X_SQL_13,X_SQL_14,X_SQL_15,X_SQL_16,X_SQL_17,X_SQL_18,X_SQL_19,X_SQL_20,X_SQL_21,X_SQL_22,X_SQL_23,X_SQL_24,X_SQL_25,X_SQL_26,X_SQL_27,... (4 Replies)
Discussion started by: thana
4 Replies

9. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

10. UNIX for Advanced & Expert Users

I am trying to find pattern between two words but unable to get that pattern..

HI.... It's fallow up file .. #./show.sh click enter button.. i am gettng the fallowup file. its keep on running every time why because there are lots of users working on it. In that file i want to search pattern between two words for ex: SELECT DISTINCT... (7 Replies)
Discussion started by: ksr.test
7 Replies
Login or Register to Ask a Question