0

I have writen a tcsh script. I have a file name and its path in a variable. For example : proj/debug/runs/filename This path can be of any length. I need just the file name at the end. Is there any way to split this string and retrieve the file name?

4

1 回答 1

0

如果您的路径存储在 shell 变量中,例如$p,那么t修饰符将执行您想要的操作:

% set filepath = /one/two/thee/four
% echo $filepath:t
four

或者,您可以使用该basename命令。

于 2013-01-25T14:41:58.357 回答