Linux – Command line tool to normalize a filename

command-line-interfacelinux

Is there a command line tool in linux that will 'normalize' a filename? i.e. remove all "xx/./xx" parts, or "myfolder/../myotherfolder" parts?

Best Answer

Actually, it is realpath: http://linux.about.com/library/cmd/blcmdl3_realpath.htm

There is also a command-line version: cyberciti.biz/faq/unix-linux-bsd-find-real-physical-path/

But on my CentOS 5 it is not available by default.

Also there is a "cheating way":

$ bash -c "cd /foo/../bar/ ; pwd"
/bar