2 problems... sed and sort

Hi everyone!

I have a file like that:

And I would it like that:

I don't know how to keep the first field and sort the second one.

I have a second question with sed...

to put the variable $VAR at the beginning of the file...
But I have an output like this:

snork :confused:

I'm confused...

Thanks a lot for your answers

For the first one...

sort -t: -k2 infile

For the second one...

sed 's/^/'$VAR':/g' infile

And useless use of cat...

for 1st, one possible solution,

for Mon in Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec; do grep "$Mon" file | sort -n -t: -k2; done

Though, we can expect some better solution.

for second, use double quotes instead single.

:wink:

Perfect guys!!!!

That's great

Thanks a lot! :stuck_out_tongue: