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

In a file , how to retrieve the lines which are the multiples of 50 ? like 50,100,150th lines etc.

9 Answers   Amazon,


There are three departments A,B and C.Write a query to display the names of all the persons( in departments other than A) who are paid higher than the person receiving the lowest salary in DEPT A

1 Answers   Wipro,


How to get the last line from a file using just the terminal?

0 Answers  


How to change our default shell?

5 Answers  


How do we delete all blank lines in a file?

0 Answers  


What language is shell scripting?

0 Answers  


What is a program shell?

0 Answers  


What is computer cli?

0 Answers  


What is the lifespan of a variable inside a shell script?

0 Answers  


how do you write sql queries using shell script for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO columns in EMP table how you display EMPNO,SAL FIELDS from emp in SHELL SCRIPT please explain with an example

4 Answers  


A file has multiple records each having three 30-bit long fields(field1,field2,field3).There is also a lookup file,LOOK_UP.dat.Now, we need to consider only the last ten digits of field1 and lookup the file LOOK_UP.dat. If there a match then field2 and field3 should replaced with corresponding data from the lookup file. otherwise that particular record,for which there is no match, should be stored in a seperate file.

2 Answers   Wipro,


c program which accept one argument as a directory name and prints all the file name along with its inode number and total count of the file in directory

1 Answers  


Categories