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?
1 Answer
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.