LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-29-2011, 06:11 AM   #1
xerox
Member
 
Registered: Mar 2011
Posts: 43

Rep: Reputation: 0
extraction of sting


Given the input :
busybox-1.11.1-1_WR3.0bg.armv6jel_vfp.rpm
i want to extract what comes before ".rpm"
i.e, busybox-1.11.1-1_WR3.0bg.armv6jel_vfp
 
Old 07-29-2011, 06:36 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
if that's a proper description of the issue, i.e. remove the .rpm suffix, just use "basename $STRING .rpm"
 
Old 07-29-2011, 06:49 AM   #3
xerox
Member
 
Registered: Mar 2011
Posts: 43

Original Poster
Rep: Reputation: 0
suppose my input is like this
busybox-1.11.1-1_WR3.0bg.armv6jel_vfp.rpm = 1.1111.2l2

i want to extract
busybox-1.11.1-1_WR3.0bg.armv6jel_vfp

from the given input line

given characters may follow ".rpm"

I dont want anything after ".rpm"

using sed or awk command
 
Old 07-29-2011, 06:49 AM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,620

Rep: Reputation: 450Reputation: 450Reputation: 450Reputation: 450Reputation: 450
Or, if you are using bash then you could use bash's own String manipulation mechanism, e.g.
Code:
echo ${STRING%.rpm*}


[edit]: Just saw your latest post. So is it correct to assume that this line is inside a file and not stored in a variable?
In this case:
Code:
sed 's/\.rpm.*$//' inputfile
You might have to provide a representative sample of you input data.

Last edited by crts; 07-29-2011 at 06:53 AM.
 
1 members found this post helpful.
Old 07-29-2011, 07:02 AM   #5
xerox
Member
 
Registered: Mar 2011
Posts: 43

Original Poster
Rep: Reputation: 0
Yes...perfect ...it worked just as i wanted it to......

Thanks a zillion....
 
  


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
[bash] sting as variable dzaku Programming 6 06-27-2011 10:31 AM
Where c++ STL sting have memory leak or Not ? kbarani Programming 0 08-27-2009 05:41 AM
Help with Conversion from Sting to Char Diederick Programming 2 11-30-2005 09:00 AM
cast from sting to int in Visual C++ Diederick Programming 3 11-29-2005 09:27 AM
Sting.h alaios Programming 2 08-21-2005 05:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:39 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