| | |
sort in unix--help
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2005
Posts: 11
Reputation:
Solved Threads: 0
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.
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)
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
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
•
•
•
•
I am working under cygwin in WindowsXP.
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
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
![]() |
Similar Threads
- how can we sort data from text file (C++)
- Unix, C++, pipe and fork (C++)
- Insertion Sort Problem (C++)
- Making a UNIX Shell, so inexperienced at it (C++)
- unix or linux ?? (Getting Started and Choosing a Distro)
- Linux/UNIX (*nix Software)
Other Threads in the C Forum
- Previous Thread: Menu items
- Next Thread: Having Few Problems!! With this program??
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory drawing dynamic executable fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation turboc unix user variable voidmain() wab windows.h





