readlink -f not working on multiple files

I tried to run readlink -f on multiple files by using wildcard "*", but it evaluates other files as operand

Command

readlink -f *log

Output (desired)

/home/trail_1.log
/home/trail_2.log

Am I doing something wrong ?
I am using tcsh and readlink is only command I am aware to read path of file.

Answer

You can also use realpath:

% realpath *
/data/code/mdweb/Gemfile
/data/code/mdweb/Gemfile.lock
/data/code/mdweb/README.markdown

realpath is not POSIX. It is available by default on FreeBSD systems, and on some (but not all) Linux systems (but AFAIK can be installed as a package on most, if not all, Linux systems).
realpath‘s behaviour might be different across implementations, so the above behaviour is not guaranteed to work. I’ve tested it on FreeBSD 10 & Arch Linux.

Attribution
Source : Link , Question Author : JigarGandhi , Answer Author : Martin Tournoij

Leave a Comment