Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just found out that ZSH's modifiers only work in interactive scripts, so the following will work correctly on the command line but not from a script (the script ignores the modifier and echoes the whole path).

for file in ~/folder/*; do
  echo ${file:t}

How can I manipulate parameters in this way from an executed script file?

share|improve this question
Where did you hear that? It works for me, as long as I make sure to execute the shell script with zsh. – mkomitee Sep 11 '12 at 12:53
@DyslexicTangent Ok, I had assumed that a source command from a .zshrc file would be interpreted using zsh. When I add the shebang it all works as expected, my bad. Add it as an answer and I'll accept it! – Gareth Sep 11 '12 at 22:49
up vote 1 down vote accepted

This should work, just make sure that you're executing the script with zsh.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .