sort in unix--help

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2005
Posts: 11
Reputation: diddle is an unknown quantity at this point 
Solved Threads: 0
diddle diddle is offline Offline
Newbie Poster

sort in unix--help

 
0
  #1
Dec 2nd, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 78
Reputation: perniciosus is an unknown quantity at this point 
Solved Threads: 4
perniciosus's Avatar
perniciosus perniciosus is offline Offline
Junior Poster in Training

Re: sort in unix--help

 
0
  #2
Dec 2nd, 2005
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
/pern.*/i

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: sort in unix--help

 
0
  #3
Dec 3rd, 2005
I am working under cygwin in WindowsXP.
I hope [s]he has sed.
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC