The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search and Parse string from inside a File SSims UNIX for Dummies Questions & Answers 2 11-08-2007 03:50 PM
how to search string and number in one file and check in the other file knshree Shell Programming and Scripting 9 08-24-2007 05:29 AM
How to search a string in a file. prathap UNIX for Dummies Questions & Answers 1 07-17-2007 03:41 AM
String search in log file sliver Shell Programming and Scripting 1 07-12-2006 08:09 AM
appending string to text file based on search string malaymaru Shell Programming and Scripting 1 06-09-2006 09:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-01-2006
swamymns swamymns is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 25
please help me to search string in a file ......

Dear Friends,
Please tell me the shell command to find desired string in a file....
for example,

file1.txt contains following text(please note that all the following tags are in single line)
----------------------------
<aaa> some text1</aaa><bbb> some text2</bbb><ccc> some text3</ccc><kkk>W/X12345</kkk><ddd> some text4</ddd><eee> some text5</eee><fff> some text6</fff><ggg> some text7</ggg><hhh> some text8</hhh>
----------------------------
please tell me how to extract "W/X12345" from the above file content..?
this paramenter,W/X12345, length may not be constant, some times it may be
W/X123
or
W/X87789989
or
W/X90798897989
ect...
please tell me how do I get this paramenter?

Please help as soon as possible.

Thanks in Advance..
swamymns
  #2 (permalink)  
Old 02-01-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
Try this :


Code:
sed -n '/<kkk>/s/.*<kkk>\(.*\)<\/kkk>.*/\1/p' file1.txt

Jean-Pierre.
  #3 (permalink)  
Old 02-01-2006
swamymns swamymns is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 25
please help me to search string in a file ......

Dear aigles, thanks for ur reply,
but I am very sorry, I have missed one important point in my previous mail.
please pardon me for that.

file1.txt contains following text(please note that all the following tags are in single line)
----------------------------
<aaa> some text1</aaa><bbb> some text2</bbb><ccc> some text3</ccc><kkk>W/X12345</kkk><ddd> some text4</ddd><eee> some text5</eee><fff> some text6</fff><kkk>3333</kkk><ggg> some text7</ggg><hhh> some text8</hhh>
----------------------------
please see that above file conatins "<kkk>" twice. i.e.,
<kkk>W/X12345</kkk>
and
<kkk>3333</kkk>

I have to extract the entire string that starts with "W/X" till the end tag("</kkk>")
i.e., I need to extract "W/X12345"

this paramenter,W/X12345, length may not be constant, some times it may be
W/X123
or
W/X87789989
or
W/X90798897989
ect...
please tell me how do I get this paramenter?


waiting for ur reply,
swamymns
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0