0

I use windows 10 and WSL2. To run linux applications on the X server hosted by the windows machine, I use the second command: export WSL_HOST_IP=$( cmd.exe /C netsh interface ip show addresses "vEthernet (WSL)" | grep "IP Address" | sed -e "s/\sIP Address:\s//g" ) and it works:

echo $WSL_HOST_IP 172.20.48.1

how do i transform it into the DISPLAY variable? what I want to get is this: DISPLAY = $WSL_HOST_IP:0.0 but I can't write ": 0.0" in bash. Anyone help me? Thanks in advance

1 Answers1

1

You need to remove DOS line ending with s/\r//:

export WSL_HOST_IP=$( cmd.exe /C netsh interface ip show addresses "vEthernet (WSL)" | grep "IP Address" | sed -e "s/\sIP Address:\s//g; s/\r//" )
Philippe
  • 20,025
  • 2
  • 23
  • 32