Computing.Net > Forums > Unix > Dynamic Variable in KSH

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dynamic Variable in KSH

Reply to Message Icon

Name: Douglas A. Maske
Date: September 22, 2003 at 07:59:31 Pacific
OS: Solaris 8
CPU/Ram: 512Mb
Comment:

I have a dynamic variable in a KSH script

The variable always starts with /abunchofdirectories/ and ends with :otherinfo

How do I strip of everything before / including / and everything after : including :



Sponsored Link
Ads by Google

Response Number 1
Name: Sean Miller
Date: September 23, 2003 at 06:05:50 Pacific
Reply:

Not sure I am 100% sure what you are asking, but "basename $variable" might do it?

ie. basename /etc/hosts => hosts

Sean


0

Response Number 2
Name: WilliamRobertson
Date: September 24, 2003 at 01:09:32 Pacific
Reply:

Or:

var="/a/bunch/of/directories/the_answer:"

var=${var##*/}
var=${var%:}

print $var


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Bypassing Sql connectivit... Polling for file arrival



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Dynamic Variable in KSH

File opening and reading in KSH www.computing.net/answers/unix/file-opening-and-reading-in-ksh/3683.html

To use variables in AWK www.computing.net/answers/unix/to-use-variables-in-awk/8025.html

datediff in ksh www.computing.net/answers/unix/datediff-in-ksh/8107.html