Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.
$ sed "s/\(^[a-z,0-9]*\)\(.*\)\( [a-z,0-9]*$\)/\1\2 \1/g" desired_file_name

I apreciate it even if you only explain part of it or at lest structure it with words as in s\alphanumerical_at_start\something\alphanumerical_at_end\something_else\global

Could someone explain what that means, why and are all regEx so ... awful ?

I know that it replaces the first lowcase alphanumerical word with the last one. But could you explain bit by bit what's going on here ? what's with all the /\ and \(.*\)\ and everything else ?

I'm just lost.

EDIT: Here is what I do get: (^[a-z0-9]*) starting with a trough z and 0 trough 9; and [a-z,0-9]*$ is the same but the last word (however [0-9,a-z] = just first 2 characters / first character, or the entire word ?). Also: what does the * or the \(.*\)\ even mean ?

share|improve this question

closed as off topic by hhlp, fossfreedom Jun 5 '12 at 17:15

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Question isn't suited to this SE site. Try stackoverflow.com –  jackweirdy Jun 5 '12 at 16:36
I understand. I thought it being linux this is the place, sorry about that. And here I have tags for both regEx and sed ... they seem to be there also, so I'll give it a shot –  Kalec Jun 5 '12 at 16:45
askubuntu is (or at least aims to be) specific to Ubuntu. RegEx can apply to lots of operating systems and programming languages so it doesn't fit here –  jackweirdy Jun 5 '12 at 17:31
add comment

Browse other questions tagged or ask your own question.