0

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?

2
  • 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, 2012 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, 2012 at 22:49

1 Answer 1

1

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

You must log in to answer this question.

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