Full path in glob in Zsh

filesglobzsh

Say I run the following on /some/path:

for x in foo/*; do
print $x
done

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.

Best Answer

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

Or:

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.

Related Question