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.

Answers were Sorted based on User's Feedback



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

Answer / xxx

ls -l|sort -nk5

Is This Answer Correct ?    21 Yes 2 No

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

Answer / 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

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

Answer / amrapalee jawalikar

ls -l | sort +4 -5

Is This Answer Correct ?    2 Yes 1 No

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

Answer / karunaprakash

Place the selected 5th coloumn in the file file1 and sort
the file1.


$ ls -l | cut -f 5 > file1
$sort file1

Is This Answer Correct ?    1 Yes 1 No

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

Answer / vikas

ls -al | sort | cut -d ' ' -f 5

Is This Answer Correct ?    2 Yes 9 No

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

Answer / rajesh

ls -l | awk '{print $5}'

Is This Answer Correct ?    7 Yes 16 No

Post New Answer

More Shell Script Interview Questions

Why should we use shell scripts?

0 Answers  


What is the command to find out users on the system?

0 Answers  


What does chmod do?

0 Answers  


What is a shell script in windows?

0 Answers  


How will you connect to a database server from linux?

0 Answers  






What is option in shell script?

0 Answers  


give me some website where i can get unix and testing meterials

1 Answers  


What are the additional egrep symbols?

2 Answers  


How important is shell scripting?

0 Answers  


HOW TO CREATE 10 USERS IN UNIX(HP-UX) USING SHELL SHELL SCRIPT?

3 Answers   Patni,


Create a bash shell script that reads a line from the user consisting of 5 words and then prints them out in reverse order. Name this script "reverse.sh"

1 Answers  


Hi, i want to zip the files that generates automatically every few minutes (files generated are in .arc extension)....any body write a script for this... thanks in advance

5 Answers   HP,


Categories