Shimano components are usually compatible between levels/families, so long as the parts are built for the same number of gears. In this case, if both bikes have the same number of gears -- 8 in the rear and 2 in the front, for example -- then yes, you'd be able to swap shifters.