All these answers rely on capturing the output. Id recommend using the aws cli builtin profile functionality for this:
export AWS_PROFILE=111111111111-my-role aws configure role_arn arn:aws:iam::111111111111:role/my-role aws sts get-caller-identity