Use htsbox:
htsbox samview -p in.bam | less -S
htsbox samview -pS in.sam | less -S
It outputs mapping positions in the PAF format, which looks something like:
read1 4983 774 4982 + chr18 80373285 26911072 26915544 3835 4631 60 \
mm:i:214 io:i:119 in:i:159 do:i:339 dn:i:423
This is one long line in terminal. I folded the line for display purposes. For the first 12 fixed fields, see the table in PAF page. They give mapping positions and identity. The optional fields tell you #mismatches (mm), #insOpens (io), #insertions (in), #delOpens (do) and #deletions (dn). Note that the alignment MUST have an "NM" tag; otherwise the number of matching bases (col. 11) is overestimated and "mm" will always be zero.
You can easily compute summary statistics from PAF if you are familiar with command lines. For example:
htsbox samview -p in.bam | awk '{x+=$10;y+=$11}END{print x/y}' # identity
htsbox samview -p in.bam | awk '$2>1000{x+=$10;y+=$11}END{print x/y}' # identity for >1000bp
htsbox samview -p in.bam \
| perl -ane '{$g+=$1 while /[id]n:i:(\d+)/g;$y+=$F[10]}END{print $g/$y,"\n"}' # gap rate
If you don't like long one-liners, feel free to write a proper script to collect all statistics in one go.