Answer by dogbane for How to obtain the absolute path of a file via Shell...
#! /bin/shecho "$(cd "$(dirname "$1")"; pwd -P)/$(basename "$1")"
View ArticleAnswer by Benjamin Bannier for How to obtain the absolute path of a file via...
Use realpath$ realpath example.txt/home/username/example.txt
View ArticleHow to obtain the absolute path of a file via Shell (BASH/ZSH/SH)?
Question: is there a simple sh/bash/zsh/fish/... command to print the absolute path of whichever file I feed it?Usage case: I'm in directory /a/b and I'd like to print the full path to file c on the...
View ArticleAnswer by Marinos An for How to obtain the absolute path of a file via Shell...
The top answers in this question may be misleading in some cases. Imagine that the file, whose absolute path you want to find, is in the $PATH variable:# node is in $PATH variabletype -P node#...
View ArticleAnswer by smac89 for How to obtain the absolute path of a file via Shell...
In zsh, yes there is.Assuming your path is stored in a variable, you can use the :P modifier to get the absolute path of the file.Example:f='../example.txt'echo ${f:P}The above will print the absolute...
View ArticleAnswer by jo_ for How to obtain the absolute path of a file via Shell...
in bash this:ls -d $(pwd)/the-fileworks also with wild cardls -d $(pwd)/*.ts
View Article