readlink not working when parameters is surrounded with double quote

I'm trying to locate the real path of the running script , but when $0 was in some folders that contains space , readlink would fail , so i surrounded $0 with " , but readlink ceased to work this time.

  RPATH="$(readlink -f \"$0\")"
  echo $RPATH

Thanks , and if bash itself can do this , it's much more better !

Answers


Don't escape the inner quotes. As it is, they are handled to readlink as part of the filename (instead of preventing word splitting).


Need Your Help

Perl to PHP function conversion - help needed

php perl

I have a subroutine/function in Perl like this:

How to reload Iframe content at a time interval so that it does not flicker

c# javascript asp.net iframe flicker

I have kept Iframe inside update panel but then also it flickers every time it reload. I think I can use javascript to load my content of Iframe in order to make it flicker free.Is this way correct...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.