How to get full path of a file?
Is there an easy way I can print the full path of
file.txt = /nfs/an/disks/jj/home/dir/file.txt
dir> <command> file.txt
Read more… Read less…
I suppose you are using Linux.
I found a utility called
realpath in coreutils 8.15.
realpath file.txt /data/ail_data/transformed_binaries/coreutils/test_folder_realpath/file.txt
As per @styrofoam-fly and @arch-standton comments,
realpath alone doesn't check for file existence, to solve this add the
realpath -e file
The following usually does the trick:
echo "$(cd "$(dirname "$1")" && pwd -P)/$(basename "$1")"
find $PWD -type f | grep "filename"
find $PWD -type f -name "*filename*"
If you are in the same directory as the file:
file.txt with your target filename.