Reputation: 571
I am attempting to sort a .txt file that is full of data. I attempt to sort the file by the first word of aa line in a manner that a dictionary would see it. (I tried the sort -d) The issue that I encounter is this-
Input file
100 Eminem:Detroit_Vs._Everybody.txt
100 Fabolous:She_Wildin'.txt
100 Fetty_Wap:Trap_Queen.txt
100 Kanye_West:All_Day.txt
10 ASAP_Rocky:Lord_Pretty_Flacko_Jodye_2.txt
10 Bon_Iver:Heavenly_Father.txt
10% Ed_Sheeran:Take_It_Back.txt
10 Florida_Georgia_Line:Dirt.txt
10 Jay_Electronica:Road_To_Perdition.txt
command: sort -d < a.txt
Output
100 Eminem:Detroit_Vs._Everybody.txt
100 Fabolous:She_Wildin'.txt
100 Fetty_Wap:Trap_Queen.txt
100 Kanye_West:All_Day.txt
10 ASAP_Rocky:Lord_Pretty_Flacko_Jodye_2.txt
10 Bon_Iver:Heavenly_Father.txt
10% Ed_Sheeran:Take_It_Back.txt
10 Florida_Georgia_Line:Dirt.txt
10 Jay_Electronica:Road_To_Perdition.txt
No change occurs at all. I'm working on a piece of code that uses this data and the way that the 10% comes in between the 10 truly messes up the application.
I would like to see
100 Eminem:Detroit_Vs._Everybody.txt
100 Fabolous:She_Wildin'.txt
100 Fetty_Wap:Trap_Queen.txt
100 Kanye_West:All_Day.txt
10 ASAP_Rocky:Lord_Pretty_Flacko_Jodye_2.txt
10 Bon_Iver:Heavenly_Father.txt
10 Florida_Georgia_Line:Dirt.txt
10 Jay_Electronica:Road_To_Perdition.txt
10% Ed_Sheeran:Take_It_Back.txt
In other parts of the file, I have similar issues not just with numbers, but with letters and words also. So how do I do this?
Upvotes: 1
Views: 196