Displacement sensing... sliding a rod inside a hollow tube

Thanks! The rod is attached to something that would move back and forth against the stationary tube for up to 30 inches, accuracy or resolution are not important. I am looking into DRO as suggested, those I found are standalone units with a big track, and no way to send data over to a computer... But I will keep looking.

Another direction I am looking into is this guy https://www.digikey.com/product-detail/en/ams/AS5311-TS_EK_AB/AS5311-AB-ND/3828353, maybe I can wire it to an arduino and send serial data to my PC. But the DRO solutions sounds a lot more simple and reliable, if I can find a way to attach the track to the rod (or let the track become the rod itself if the diameter is around 0.75"), and send data over to a PC.