After typing the command
$ cd onos
$ cat << EOF >> ~/.bash_profile
export ONOS_ROOT="`pwd`"
source $ONOS_ROOT/tools/dev/bash_profile
EOF
$ .~/.bash_profileI 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
.thesource-d filename:. ~/.bash_profilesecond 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_ROOTin 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 ... EOFany one of the above would do.