Some data formats like the NDF demand that only the file name (i.e. what appears before the last dot) be given in commands. To achieve this you must first strip off the remainder (the file extension or type) with the :r file modifier.
foreach file (*.sdf)
histogram $file:r accept
end
This processes all the HDS files in the current directory and calculates an histogram for each of them using the histogram command from KAPPA. It assumes that the files are NDFs. The :r instructs the shell to remove the file extension (the part of the name following the the rightmost full stop). If we didn't do this, the histogram task would try to find NDFs called SDF within each of the HDS files.
C-shell Cookbook