LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 01-05-2007, 06:34 AM   #1
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Rep: Reputation: 79
Variable modification in script


Hi there

I'm meating an issue with my variable in my bach script.

my variable look somthing like this:

Code:
Fullpath=../../myfile.cc
but some times i need to retrive
../../myfile.cc
and some other time i just need:
myfile


so i manage to remove the ".cc" by doing this:
Code:
echo ${Fullpath%.cc}
but how to remove "../../" ?



Thanks,
Angel.
 
Old 01-05-2007, 06:38 AM   #2
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
echo (Fullpath#../../)
 
Old 01-05-2007, 07:01 AM   #3
demon_vox
Member
 
Registered: May 2006
Location: Argentina
Distribution: SuSE 10
Posts: 173

Rep: Reputation: 30
You can also do this:

Code:
basename "$Fullpath"
Besides you can also use basename to remove a suffix. For instance


Code:
basename "$Fullpath" ".cc"
Will remove the ".cc".


Hope this is useful.

Cheers!
 
Old 01-05-2007, 10:00 AM   #4
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Original Poster
Rep: Reputation: 79
Thumbs up

Yes, this was really helpfull.

You solve my issue.

Thanks,
Angel.

 
  


Reply



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
Get file modification date/time in Bash script cmfarley19 Programming 16 04-15-2015 06:25 PM
script string modification Ammad Linux - Newbie 10 01-07-2007 08:37 AM
script for email modification Ateo General 1 08-29-2006 05:00 PM
setting a variable variable in a script... this works, but could it be more elegant? pwc101 Programming 3 08-18-2006 11:23 AM
How can I do some modification to my initialized "env" environment variable? yuzuohong Linux - General 3 12-18-2002 03:41 PM

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

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