Search Character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search Character
# 1  
Old 11-05-2010
Search Character

Hi,

I need to search the "BP1418" in xml file(the letter BP remain constant but the number changes randomly and it will be in double quotes) . Can you please let me know how to find these charater in unix.

thanks
# 2  
Old 11-05-2010
egrep '"BP[0-9]+"' file.xml will report the whole line it's on. If you want only the number:

egrep -o '"BP[0-9]+"' file.xml
# 3  
Old 11-05-2010
Thanks for reply.. but i want to print that charater..
# 4  
Old 11-05-2010
And that doesn't? It looks like it does to me.
Code:
$ echo 'stuff asdf <tag> <tag param="BP1418">' > file.xml
$ egrep -o '"BP[0-9]+'" file.xml
"BP1418"
$

If that's not what you wanted, please explain more clearly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search a character and replace it with multiple lines

This is for AIX 6.1, I've a flat file and the format is like this DECLARE some statements; BEGIN some statements; END; I've to search BEGIN and replace it with the following 4 lines BEGIN For x in 1..1 LOOP BEGIN Similarly I've to search END and replace it with the... (7 Replies)
Discussion started by: Mukul Sharma
7 Replies

2. UNIX for Dummies Questions & Answers

Search for a particular word and replace the first character

Hi Unix gurus, I've a dna sequence in a file format known as fasta format (sequence header starts with > and ignored), an example shown below: >sequence_1 CGTATTCTCCGAATACC ATACG >sequence_2 CAGATTTTCAAATACCCCC In a file like this I want to do the following three search and replace. The... (4 Replies)
Discussion started by: Fahmida
4 Replies

3. Shell Programming and Scripting

Ls help: ls not working with start character search (^)

Experts, How to list a file using ^ character, for all files started with character a. (os= hp-ux ) # ls -l -rw------- 1 useradm users 0 Mar 26 14:30 abc -rw------- 1 useradm users 0 Mar 26 14:30 def -rw------- 1 useradm users 0 Mar 26... (7 Replies)
Discussion started by: rveri
7 Replies

4. Shell Programming and Scripting

awk search for space character

How do I use awk to search for a string that contains a space bar? I have tried this awk '/send email/ {print $0}' input awk '/send\ email/ {print $0}' input (1 Reply)
Discussion started by: locoroco
1 Replies

5. UNIX for Dummies Questions & Answers

how to search and list file with wildcard character

hi, I want to search all files in the current working direcotry and to print in comma (,) seperated output. But I have two patterns to search for. Files will be in ABC20100508.DAT format. Search should happen on the format (ABC????????.DAT) along with date(20100508). I can do a ls... (2 Replies)
Discussion started by: anandapani
2 Replies

6. UNIX for Dummies Questions & Answers

global search and replacement of a non-ascii character

Hi, I need to do a global search and replacement of a non-ascii character. Let me first give the background of my problem. Very frequently, I need to copy set of references from different sources. Typically, a reference would like this: Banumathy et al., 2002 G. Banumathy, V. Singh and U.... (1 Reply)
Discussion started by: effjay
1 Replies

7. Shell Programming and Scripting

Need to search and replace based on character count

Hi, I wanted to add a newline character after every 100 characters in a file using a awk or shell without reading each line of the file. I want to run a command on the complete file. This does based on a string but i want to add a new line after every 100 characters ir-respective of the... (3 Replies)
Discussion started by: vijaykrc
3 Replies

8. UNIX for Dummies Questions & Answers

to search for a particular character in a word

Hi I would like to accept in a string from user like username/pwd@dbname suppose the user does not input @ then i should throw an error that @ symbol missing . How to achieve this Thanks in advance Suresh (6 Replies)
Discussion started by: ssuresh1999
6 Replies

9. Shell Programming and Scripting

Search in variable for character

qwertyuioplkjhgfdsa (1 Reply)
Discussion started by: rorey_breaker
1 Replies

10. Shell Programming and Scripting

Search for a non zero character in file

Hi, I have a log file which has entries as Staged 0 records from fn.dat (0 failed) 01/01 01:01:01 I 0 Error Transactions I want to find out any line that has an entry like "(1 failed)" or "(2 failed)" or any number in general ( >0 ) similarly it should search for string like "1... (4 Replies)
Discussion started by: misenkiser
4 Replies
Login or Register to Ask a Question