Your using the wrong keyboard layout.
Full Raspbian or Lite? In the full Raspbian you just go to Preferences > Raspberry Pi Configuration via the menu and change your keyboard layout. Localization tab . keyboard layout. The default is English UK, I set mine to English US > English US with Eruo on the 5. That matches everything up for me.
If it’s Raspbian lite you need to run sudo raspi-config to do it. Menu’s are bit different but its the same idea. Finding the right keyboard layout is tricky though, its the old interface.
I had the same issue from terminal in Raspbian lite, I could not get the | symbol on my keyboard even after trying a few different layouts. I eventually gave up and went to full Raspbian.