Maybe I am searching wrong, but I cannot find any solution for this...
I want to use a shell script to append the following to my bashrc file (to make the installation of Windows Subsystem for Linux easier):
# Load X display (run 'XLaunch' on Windows with 'Disable access control' checked and 'Native opengl' unchecked!) # https://sourceforge.net/projects/vcxsrv/ export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0 This is my script.sh:
### Add useful stuff to bashrc ### -------------------------- echo " # Load X display (run 'XLaunch' on Windows with 'Disable access control' checked and 'Native opengl' unchecked!) # https://sourceforge.net/projects/vcxsrv/ export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0 " >> ~/.bashrc This is what is appended to bashrc when running script.sh:
# Load X display (run 'XLaunch' on Windows with 'Disable access control' checked and 'Native opengl' unchecked!) # https://sourceforge.net/projects/vcxsrv/ export DISPLAY=172.19.96.1:0.0 Since my IP may change, I want to append the raw command itself to bashrc, not the output of the command. I am sure this must be a duplicate question, but I cannot find a useful answer. There are just to many answers that simply refer to echo or cat. cat yields the same undesired result:
cat <<EOF >> ~/.bashrc # Load X display (run 'XLaunch' on Windows with 'Disable access control' checked and 'Native opengl' unchecked!) # https://sourceforge.net/projects/vcxsrv/ export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0 EOF
'EOF') to prevent the here-document content from being expanded.