This is the full text from Buddhist Monastic Code:
Intention. The Vinītavatthu contains cases of a bhikkhu who caresses his mother out of filial affection, one who caresses his daughter out of fatherly affection, and one who caresses his sister out of brotherly affection. In each case the penalty is a Dukkaṭa.
The Vibhaṅga does not discuss the issue of bhikkhus who intentionally make active contact with women for purposes other than lust or affection — e.g., helping a woman who has fallen into a raging river — but the Commentary does. It introduces the concept of anāmasa, things carrying a Dukkaṭa penalty when touched; women and clothing belonging to a woman top the list. It then goes into great detail to tell how one should behave when one’s mother falls into a raging river. Under no circumstances, it says, should one grab hold of her, although one may extend a rope, a board, etc., in her direction. If she happens to grab hold of her son the bhikkhu, he should not shake her off, but should simply let her hold on as he swims back to shore.
Where the Commentary gets the concepts of anāmasa is hard to say. Perhaps it came from the practices of the Brahmin caste, who are very careful not to touch certain things and people of certain lower castes. At any rate, there is no direct basis for it in the Canon. Although the concept has received universal acceptance in Theravādin Communities, many highly‑respected Vinaya experts have made an exception right here, saying that there is nothing wrong in touching a woman when one’s action is based not on lust, but on a desire to save her from danger. Even if there is an offence in doing so, there are other places where Buddhaghosa recommends that one be willing to incur a minor penalty for the sake of compassion (e.g., digging a person out of a hole into which he has fallen), and the same principle surely holds here.
So, shaking a woman's hand with the intention to avoid being impolite, or touching a woman to help her, not being lustful, nor out of affection, are no offence. However, touching or hugging out of affection are an offence of wrong-doing.
If a woman tries to shake my hand, I usually explain how to greet a bhikkhu by holding the hands in añjali, if circumstances are