LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-20-2008, 02:04 AM   #1
swift2008
Member
 
Registered: Jul 2008
Posts: 78

Rep: Reputation: 15
text truncate


Hi all
i have some text like this
Quote:
Host/PCI; Bridge Device 8086 2970 [Intel] no device name found: no device description found // SubIDs 17aa 1015 Legend: no-name
i need to truncate the text like this and i need to put this truncated text in the gtk label..the output shown like this.

label1->Host/PCI; Bridge Device
label2->VID: x8086 Intel Corporation
label3->DID:x2970 no device name found: no device description found
label4->SubVID: x17AA legend
label5->SubID: x1015 no-name

the above text are truncated from "Host/PCI; Bridge Device 8086 2970 [Intel] no device name found: no device description found // SubIDs 17aa 1015 Legend: no-name"

ans also i had some text like this "1015 17AA <2C : SubID SubVendorID"
i need to get the text "1015 17AA".
the output should be "x101517AA"

any help it should be appreciated

Last edited by swift2008; 10-20-2008 at 02:10 AM.
 
Old 10-21-2008, 03:34 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
Ummm ... with a single line of input that has no obvious delimiters
for what you seem to use as fields of some sort I don't think you're
going to get much feed-back on your problem.



Cheers,
Tink
 
Old 10-21-2008, 07:18 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.3
Posts: 17,537

Rep: Reputation: 2420Reputation: 2420Reputation: 2420Reputation: 2420Reputation: 2420Reputation: 2420Reputation: 2420Reputation: 2420Reputation: 2420Reputation: 2420Reputation: 2420
1. you mean extract, not truncate

2. agree with Tink, your sub-fields look a bit arbitrary. Are they always like that, or can the contents vary much?
In either case, I'd use Perl to do intelligent parsing of the string(s). Start with the split(), index() and substr() cmds.
http://perldoc.perl.org/index.html
http://www.perlmonks.org/?node=Tutorials
 
  


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
how to truncate munna_dude Programming 5 07-25-2007 11:56 PM
how can i truncate this munna_dude Linux - Networking 1 06-15-2007 11:42 PM
how can i truncate this munna_dude Programming 24 04-12-2007 03:44 AM
truncate a text file in CLI? hottdogg Linux - General 2 09-06-2005 09:32 PM
how to use truncate sureshbabu Linux - Newbie 1 10-29-2003 04:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:53 AM.

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