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

What are the different commands available to check the disk usage?

497


How do I run a .sh file?

620


What are the types of script?

622


How does ls command work?

591


Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.

2037






What will happen to my current process when I execute a command using exec?

540


What is scripting used for?

568


Is scripting and coding the same thing?

568


What language is bash written in?

568


Is shell scripting difficult?

559


Is shell scripting a programming language?

581


How to pass an argument to a script?

597


How do I open the shell in cmd?

531


what is tickets $ what low,medium,high priorite pls define time also

1725


How will you emulate wc –l using awk?

914