Ordered list of names (Bash)

0

I am trying to use a single command in Bash that allows me to see the contents of a text file in list format and in alphabetical order.

The text file contains surnames of several people but they are separated by spaces, and not by lines. Also, they are not ordered alphabetically.

    
asked by aprendiz 05.09.2018 в 16:32
source

1 answer

1

You can replace the spaces with line breaks with tr and then sort them with the sort command. In a single line:

tr ' ' '\n' < nombres.txt | sort

Using cat

cat nombres.txt | tr ' ' '\n' | sort
    
answered by 05.09.2018 в 17:31