0

I have a file with one word on each line and I want to sort the file alphabetically. There's 2050 words in the file, so doing it manually would take a long time. Is there a bash script to sort it alphabetically and rewrite it to the file?

3

Yes it's sort [file name]. That prints the sorted list to your terminal. If you want to redirect it to a file you can do sort [original file] > [sorted file]. If you have items starting with numbers, you can do sort -h insted of sort for a more intuitive sorting.

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.