LinuxQuestions.org
Help answer threads with 0 replies.
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, 11:52 AM   #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, 11:54 AM   #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, 12:06 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
name=${name/%cdt/wlg}
this substitutes the substring "cdt" that matches at the back end of the string.
 
Old 06-17-2008, 12: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 04:55 PM
Getting part of variable p0tw0r Programming 3 04-11-2005 02:25 AM
Print a part of variable/string p0tw0r Linux - Newbie 1 04-07-2005 02:49 PM
unsetting a part of ENV variable praveenv Linux - Newbie 3 08-28-2004 09:36 AM
How to modify the library path variable?modify the Electronkz Linux - Newbie 1 04-13-2004 06:18 AM

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

All times are GMT -5. The time now is 05:43 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
Open Source Consulting | Domain Registration