A British doctor has said he punched a shark on the nose to escape its jaws while surfing off the Australian coast.

Charlie Fry, 25, was left with superficial puncture wounds on his right shoulder and upper arm after the attack on Monday afternoon off Avoca Beach, 60 miles north of Sydney.

Dr Fry, who has worked at the nearby Gosford Hospital for the past two months, said he had recently watched a video on YouTube in which Australian professional surfer Mick Fanning told of punching a great white shark to escape an attack unscathed during a surfing competition in South Africa in 2015.

"So when it happened, I was like, 'Just do what Mick did. Just punch it in the nose'," he told Nine Network television.

"So Mick, if you're watching or listening, I owe you a beer. Thank you very much."

Dr Fry, a surfing beginner, was with three doctor friends when he was attacked.

"I was out surfing and I got this massive thud on my right-hand side, it completely blindsided me.

"I thought it was a friend goofing around. I turned and I saw this shark come out of the water and breach its head.

"So I just punched it in the face with my left hand and then managed to scramble back on my board, shout at my friends and luckily a wave came, so I just sort of surfed the wave in."

Dr Fry said he was not aware of his injured and bleeding arm until he reached the shore.

"I didn't really notice it at the time because when you're surfing, all I'm thinking was, 'I'm about to die. I'm literally about to die'.

"So I thought, 'get in as fast as possible, ride the wave for as long as you can and then just start paddling for your life'."

His friends drove him to Gosford Hospital, where they all work, rather than waiting for an ambulance. The beach was closed for 24 hours.

Dr Fry said he could not return to the ocean for a week due to his injuries, but "after then, I'll be racing to get back in".