How to sort a result of Ls -l command based on columns. Ex.
i want to sort 5th column from output of ls -l command.

Answer Posted / kiran

$ ls -al | sort -n -k5

The -n in my example means "sort numerically", and the -k5
option means to key off of column five. Like other Unix
commands, these options can be combined and shortened, like
this:

$ ls -al | sort -nk5

Is This Answer Correct ?    13 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why are there shells on the beach?

589


‎What is a shell? · ‎Types of shell · ‎what is shell scripting?

549


What does $$ mean in shell script?

574


In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?

636


What is shell chemistry?

534






What is a shell script? Can you name some of its advantages?

525


How do you create a shortcut in linux?

589


What is batch file programming?

689


What is the difference between bash and shell?

639


Explain about return code?

632


How does shell scripting work?

608


Is shell a scripting language?

570


Suppose you execute a command using exec, what will be the status of your current process in the shell?

573


What is meant by $1 in shell script?

546


What is the difference between scripting and coding?

533