FG

How to sort ls by column in Ubuntu via piping to sort?

Fresh3 days ago
Mar 15, 202613794 views
Confidence Score0%
0%

Problem

I'm a Linux newbie trying to learn how piping works in the Ubuntu terminal. I tried to sort by file size: The files were listed in this order: This is obviously a fail in terms of sorting by file size. I tried with a bunch of other columns in addition to , and repeatedly get muddled, out of order, …

Error Output

ls -al | sort -k5

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to sort ls by column in Ubuntu via piping to sort?

Low Risk

The output you show is sorted alphabetically instead of numerically. Try adding: , compare according to string numerical value Edit: I just noticed that in your output the file size column appears to be the 6th one! have you tried ? Tested on my Har…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment