Bash version of the script adopted