It can be done with sed using the following incredibly obfuscated script:
sed -e 'h;s/ .*//;x;s/[^ ]* //;y/AZERTYUIOPQSDFGHJKLMWXCVBN/azertyuiopqsdfghjklmwxcvbn/;H;x;s/\n/ /' your_file
Explained:
The first part of the script (h;s/ .*//;x;s/[^ ]* //
) puts the part a the line before the 1st space in the hold space and the part of the line after the 1st space in the pattern space:
h
: copies the actual line in the hold space.
s/ .*//
: keeps in the pattern space only characters before the 1st space.
x
: switch hold and pattern space.
s/[^ ]* //
: keeps in the pattern space only characters after the 1st space.
Ok, now we have the 1st part of the line in the hold space, and the 2nd in the pattern space. We need to put the 2nd part in lower case, so we use y/AZERTYUIOPQSDFGHJKLMWXCVBN/azertyuiopqsdfghjklmwxcvbn/
(yes, I have an AZERTY keyboard).
Then, it is only a matter of getting back the 1st and 2nd part of the files together:
H
: append pattern space to hold space.
x
: exchange pattern space and hold space.
s/\n/ /
: replace the \n
of the H
command by a space.
I hope you are not to disgusted by sed synthax ;-).