Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

Say I run the following on /some/path:

for x in foo/*; do
print $x

Are there any parameters I can use to tell Zsh to print, not just the filename, but the full absolute path to $x? (without explicitly hard-coding /some/path in the print statement.

share|improve this question
up vote 5 down vote accepted
for x (foo/*(:A)) print -r $x


for x (foo/*) print -r $x:A

Though in this case:

print -rl foo/*(:A)

is enough.

:A expands symbolic links. You can also use :a which doesn't.

share|improve this answer

You can use the a history expansion modifier in a glob qualifier.

for x in foo/*; do
    print -r $x(:a)

With :A instead of :a, symbolic links are expanded.

share|improve this answer

If you prepend the path to the pattern, $x will expand to the full path:

for x in /some/path/foo/*; do
  print $x

But I'm not sure if this is exactly what you're looking for?

If you don't want to hardcode /some/path and you want the code always to look in the current directory, use $PWD:

for x in $PWD/foo/*; do
  print $x
share|improve this answer

Your Answer


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.