Timeline for How to obtain the absolute path of a file via Shell (BASH/ZSH/SH)?
Current License: CC BY-SA 2.5
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 13, 2010 at 15:43 | comment | added | dhardy | Sorry, but I don't see the point. I already provided an answer as a script with more features that this and it doesn't need to be used within a shell script. | |
Oct 12, 2010 at 19:58 | comment | added | Roman Cheplyaka | Strictly speaking, under POSIX behaviour of echo is undefined if arguments contain backslashes. However, it is defined under XSI extension (namely, echo should interpret the escape sequences). But both bash and zsh are soo far even from POSIX compliance... | |
Oct 12, 2010 at 18:29 | comment | added | hluk | Again, you're right! Really, the behavior of echo command in zsh is different from bash. | |
Oct 12, 2010 at 18:28 | history | edited | hluk | CC BY-SA 2.5 |
printf instead of echo
|
Oct 12, 2010 at 17:52 | comment | added | Roman Cheplyaka |
To improve further, replace echo "$1" with printf "%s\n" "$1" (same with the second echo). echo may interpret backslashes inside its arguments.
|
|
Oct 12, 2010 at 17:43 | history | edited | hluk | CC BY-SA 2.5 |
grep removed
|
Oct 12, 2010 at 17:31 | comment | added | Roman Cheplyaka | Looks portable to me. On the other hand, will break for example on a filename containing a newline. | |
Oct 12, 2010 at 14:59 | history | answered | hluk | CC BY-SA 2.5 |