Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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}
done

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
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.