bash: .~/.bash_profile: No such file or directory

After typing the command

$ cd onos
$ cat << EOF >> ~/.bash_profile
export ONOS_ROOT="`pwd`"
source $ONOS_ROOT/tools/dev/bash_profile
EOF
$ .~/.bash_profile

I get an error

bash: .~/.bash_profile: No such file or directory

1 Answer

Two issues:

  • your main problem is pretty simple; you need a whitespace between . the source-d filename:

    . ~/.bash_profile
  • second issue you overlooked is that the variable expansions inside the here doc (<<) would happen in this shell i.e. the variables won't be preserved in ~/.bash_profile. So, ONOS_ROOT in your example, would be set and expanded to the $PWD. You need to use any form of escaping on the End of File marker to keep the variable from expansing inside here doc:

    $ cat <<"EOF" >> ~/.bash_profile
    ...
    EOF
    $ cat <<'EOF' >> ~/.bash_profile
    ...
    EOF
    $ cat <<\EOF >> ~/.bash_profile
    ...
    EOF

    any one of the above would do.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like