LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-22-2011, 03:20 AM   #1
hweontey
LQ Newbie
 
Registered: Feb 2011
Posts: 1

Rep: Reputation: 0
Extract substring using sed


I would like to extract a substring using sed.

the String is :
[1365465464.1654] fasfa fsaf df16A fas 2.2 (7/2134)

number result :
16A
 
Old 02-22-2011, 03:27 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Hi and welcome to LinuxQuestions!

First you should clarify what are the criteria to uniquely identify the substring, e.g. is it always in the 4th field or is it always preceded by the df prefix? Then you can select the string using parentheses in the pattern and \1 in the replacement string. Take a look at Sed - An Introduction and Tutorial, here for more details. Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
extract substring from string in C baddah Programming 6 02-02-2010 04:22 AM
extract substring using sed and regular expressions (regexp) lindylex Programming 20 12-22-2009 10:41 AM
Extract a substring from a line in a faill PMichaud Programming 4 12-16-2009 01:29 PM
Extract a substring prpersonal Linux - General 8 10-19-2009 02:44 PM
Extract a substring prpersonal Linux - Newbie 2 10-19-2009 08:05 AM


All times are GMT -5. The time now is 04:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration