#! /bin/bashfile="$@"realpath "$file" 2>/dev/null || eval realpath $(echo $file | sed 's/ /\\ /g')
This makes up for the shortcomings of realpath
, store it in a shell script fullpath
. You can now call:
$ cd && touch a\ a && rm A 2>/dev/null $ fullpath "a a"/home/user/a a$ fullpath ~/a\ a/home/user/a a$ fullpath AA: No such file or directory.