How to sort lines of files on Linux by just the first character

If you need to order a file just by the first character then you can use this command:

$ sort -k1.1,1.1 filename

It will show the result in the standard output, then append “> newfile” to above command to create a new file with sorted lines.

Source: http://stackoverflow.com/questions/6297906/linux-sort-only-by-the-first-letter-of-each-line

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s