SelMez
SelMez

Reputation: 41

How to print a part of a filename using Tcl

I want to print a part of filename in Tcl like ....
Suppose I have a set string "/home/Documents/galaxy/my_folder" and instead of puts $string to get the whole string, I want to print my_folder only.
How can I do so ? please suggest if there is any appropriate Tcl command.

Upvotes: 1

Views: 347

Answers (1)

Jerry
Jerry

Reputation: 71598

To get the last component from a path, you would use file tail:

file tail $string

And if you happen to want it using puts:

puts [file tail $string]

Upvotes: 4

Related Questions