I would like to sort the temp.txt contains like the following.


1_r0.png
1_r10.png
1_r100.png
1_r105.png
1_r15.png
1_r150.png
1_r155.png
1_r160.png
1_r20.png


I want the sorted result to be

1_r0.png
1_r10.png
1_r15.png
1_r20.png
1_r100.png
1_r105.png
1_r150.png
1_r155.png
1_r160.png
like the above.
Anybody can help me?
I used sort -n temp.txt sort.txt
But it is not working correctly.
I am working under cygwin in WindowsXP.

Lol, so now I'm not an expert on linux utilities but I enjoy tinkering with it now and then... This is one way to solve _this_ problem, somehow I thought it would be possible to use the -k flag for start of key value for sort (btw this is not a c question as such I think)...
but this did the trick (for this case) sed -e 's/1_r//' temp.txt | sort -n | xargs --replace=num echo l_rnum > output.txt

I am working under cygwin in WindowsXP.

I hope [s]he has sed. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.