:m $
- Move current line to bottom
:%s/\v(\w*) (\w*)/\2, \1/g
- For second part
سؤال
I am taking a UNIX class, and unfortunately my teacher is not the greatest..So I am in need of your help!
I have a file named file1 with the text:
Roger Mancuso
Xavier Allen
Paul Bibbens
What our teacher wants us to do is with a single command first move the top line of the file to the bottom so it will look like:
Xavier Allen
Paul Bibbens
Roger Mancuso
And then using an ex command we have to take the first names, and move them after the last names, and separate them with a comma as such:
Allen, Xavier
Bibbens, Paul
Mancuso, Roger
Any help you guys could provide would be greatly appreciated, I tried going to my teachers office hours today to ask him about this and he basically told me to get lost, so now I have no idea what is going on..
Thank you so much!
المحلول
:m $
- Move current line to bottom
:%s/\v(\w*) (\w*)/\2, \1/g
- For second part
نصائح أخرى
What about this for the second part?
:%s/\(.*\)\, \(.*\)/\2, \1/g
parentheses save what they match into variables which you can access as \1 \2 \3 etc.