I want to design bash script in unix and this bash return full path because I want to use this file in other places.
Are you looking for the full path and filename of the running script?
if [ "
echo " Filename: $_my_name"
echo "Absolute path: $_my_path"
echo "Full Path + Name: $0"
Since this question is not trying to answer the harder question of converting a path with symbolic links into a physical path (w/o any links), but rather just get the directory and/or full path to the original script, there is a simpler solution (broken down in this example into components for legibility, plus you may want to use any of these pieces individually):
Your test cases should involve calling this script with an absolute path, relative path, "sourcing" it, etc., and always ending up with the directory containing the script.