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 06-17-2008, 12:52 PM   #1
pdklinux79
LQ Newbie
 
Registered: Jun 2008
Posts: 29

Rep: Reputation: 15
how to modify only the last part of the variable


here is a variable
$name=000000000002312.cdt

after using it in a process
then it is required by the program to change the variable
$name=000000000002312.wlg

how can it be accomplished , in bash shell script.

Thank you
 
Old 06-17-2008, 12:54 PM   #2
pdklinux79
LQ Newbie
 
Registered: Jun 2008
Posts: 29

Original Poster
Rep: Reputation: 15
Another Note: the variable when assinged first is an user input.. after that, we need it to change only the extensions.. i dont know how to do it..
 
Old 06-17-2008, 01:06 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Code:
name=${name/%cdt/wlg}
this substitutes the substring "cdt" that matches at the back end of the string.
 
Old 06-17-2008, 01:10 PM   #4
pdklinux79
LQ Newbie
 
Registered: Jun 2008
Posts: 29

Original Poster
Rep: Reputation: 15
Thank you . It is working.. am a newbie.. Appreciate ur prompt help..
 
  


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 use environment variable as part of filename beeblequix Linux - Newbie 3 07-11-2006 05:55 PM
Getting part of variable p0tw0r Programming 3 04-11-2005 03:25 AM
Print a part of variable/string p0tw0r Linux - Newbie 1 04-07-2005 03:49 PM
unsetting a part of ENV variable praveenv Linux - Newbie 3 08-28-2004 10:36 AM
How to modify the library path variable?modify the Electronkz Linux - Newbie 1 04-13-2004 07:18 AM


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