CSH: How to tokenize a string
<p>I'm making a CSH script where I am looping through the file names in a directory:</p>

<pre><code>foreach i ($INPUTDIR/*)
     $i
end
</code></pre>

<p>i ends up being something like this:</p>

<pre><code>/dir1/dir2/dir3/dir4/fileNameHead_middle_2016080924
</code></pre>

<p>My question is, using CSH, how can I tokenize each path, first splitting on the forward slashes, then on the underscores, collecting only the last token?</p>