Quantcast
Channel: How to obtain the absolute path of a file via Shell (BASH/ZSH/SH)? - Stack Overflow
Browsing all 46 articles
Browse latest View live

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 Article


Answer by Benjamin Bannier for How to obtain the absolute path of a file via...

Use realpath$ realpath example.txt/home/username/example.txt

View Article


How 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 Article

Answer 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 Article

Answer 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 Article


Answer 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
Browsing all 46 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>