understand sed

cat teledir.txt
jai sharma 25853670
chanchal singhvi 9831545629
anil aggarwal 9830263298
shyam saksena 23217847
lalit chowdury 26688726

If i use the below command , it is giving me the output with "," in between two name. how ? and also i would like to know the reason for the space used in between ([a-z]\) *\([a-z]\) and \2, \1/' and what is the use of specifying two [a-z] and what *\ means?

sed 's/\([a-z]*\) *\([a-z]*\)/\2, \1/' teledir.txt | sort

aggarwal, anil 9830263298
chowdury, lalit 26688726
saksena, shyam 23217847
sharma, jai 25853670
singhvi, chanchal 9831545629

Because you told it to with \2, \1 (the "replacement" string)

to separate given from family name

to swap and separate family from given name

one for given, one for family name

Nothing. * is the repeater/multiplier for the preceding "atom" (character(s)), \ escapes the char to follow.

May I advise reading man sed and man regex ?