0

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

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.

  • I entered the command : cat <<\EOF>> ~/.bash_profile > export ONOS_ROOT=" pwd " > source $ONOS_ROOT/tools/dev/bash_profile > EOF and the error was $ . ~/.bash_profile bash: /tools/dev/bash_profile: No such file or directory bash: pwd/tools/dev/bash_profile: No such file or directory bash: pwd/tools/dev/bash_profile: No such file or directory bash: pwd/tools/dev/bash_profile: No such file or directory bash: source: /bin/pwd: cannot execute binary file – pranav Jul 31 '18 at 9:52
  • @pranav You have run it wrong. I've edited to clarify further; please check the edits. – heemayl Jul 31 '18 at 10:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.