-1

I recieved a text file and i'm supposed to break it down to words and do several other things to them.. (not the issue).

the last step was to sort this list of words alphabetically, but when i used the sort command it presented the occurences of numbers prior to words.

how can i sort this list such that words will appear before numbers.

thanks in advance.

  • please edit the question and post sample from your file – Wissam Roujoulah Nov 30 '16 at 10:59
0

How about sorting the two sets of lines separately: grep -v '^[[:digit:]]' yourfile|sort && grep '^[[:digit:]]' yourfile|sort The first grep matches any line that doesn't start with a digit, the second grep does the opposite.

0

Have you tried numeric sort?

cat test.txt
854156
aaa
3453
124547u
bbb
6536
ddd
ccc

sort -n test.txt
aaa
bbb
ccc
ddd
3453
6536
124547u
854156

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.