Timeline for How to obtain the absolute path of a file via Shell (BASH/ZSH/SH)?
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 21, 2016 at 2:43 | comment | added | user48956 | Fails if there are multiple matches for the filename below $PWD. Can be painfully slow if there are many directories. | |
Jul 29, 2015 at 18:15 | comment | added | Mark Stosberg | This fails if the file name is given as "./filename.txt" (with leading dot and slash). | |
Nov 27, 2014 at 11:58 | comment | added | mc0e | @jonny: $PWD/$filename fails if $filename is already absolute. | |
Nov 27, 2014 at 11:57 | comment | added | mc0e | This approach can be improved with use of -maxdepth 1. Also don't forget about quoting - potential security issues here, depending how you use this. | |
Apr 24, 2014 at 19:05 | comment | added | jonny |
If you rely on PWD , you could simply use $PWD/$filename .
|
|
Mar 3, 2014 at 13:36 | history | edited | Matteo Italia | CC BY-SA 3.0 |
added 19 characters in body
|
Jan 1, 2013 at 19:05 | comment | added | simbo1905 | i did not grok this comment on the first read; the key point here is that if you give an absolute path to the find command then it will output results in absolute path. so using $PWD is the absolute path of where you are so you get the output as absolute. | |
Oct 12, 2011 at 16:26 | history | answered | lessthanideal | CC BY-SA 3.0 |