I'm trying to split the following string : Groups/Group#1.rpt to get only the word Group#1.rpt using tcl ; I did the following but the output was empty :
set verifyFile "Groups/Group#1.rpt"
set verify_file_name [echo $verifyFile |cut -d "/" -f 2]
This is a job for a specific built-in: file tail!
set verify_file_name [file tail $verifyFile]
Don't use string manipulation directly for this; there are some complex nuances on different platforms. This command handles all the tricky edge cases for you.
echocommand is not builtin Tcl, but your particular Tcl interpreter allows it and other shell commands. Callingechoprints to stdout, it does not return a value. The pipe operator afterechois probably piping to a subshell that does thecutand then exits the subshell. Using just pure Tcl, like thesplitorfile tailcommands will do what you expect.