简体   繁体   中英

How to convert git log --pretty=format:%aN,%ae in a specific format?

I would like to convert git log --pretty=format:%aN,%ae in a specific format.

Orginal output of git log --pretty=format:%aN,%ae :

Yu-Cheng Ling,ycling@google.com
A. Unique TensorFlower,gardener@tensorflow.org
TensorFlower Gardener,gardener@tensorflow.org
A. Hugo Ronr,garer@yahoo.org
...more

The desired conversion should look as follows:

Yu-Cheng Ling,ycling@google.com, google
A. Unique TensorFlower,gardener@tensorflow.org, tensorflow
TensorFlower Gardener,gardener@tensorflow.org, tensorflow
A. Hugo Ronr,garer@yahoo.org, yahoo
...more

Any hints or tips? Or rather, how would you solve the problem?

Could someone please help me?

Thanks

If your data does not contains sub-domains something like this would work:

$ git log --pretty=format:%aN,%ae | sed -r 's/@(.+)(\..+)/@\1\2, \1/'

Yu-Cheng Ling,ycling@google.com, google
A. Unique TensorFlower,gardener@tensorflow.org, tensorflow
TensorFlower Gardener,gardener@tensorflow.org, tensorflow

If there are sub domains, the result would be:

TensorFlower Gardener,gardener@blog.tensorflow.net, blog.tensorflow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM