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

What is use of "cut" command?

3 Answers  


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

0 Answers  


What are the different types of variables used in shell script?

0 Answers  


Is shell scripting easy to learn?

0 Answers  


What is a shell made of?

0 Answers  






Write down the syntax for all the loops in shell scripting.

0 Answers  


What is bash used for?

0 Answers  


wats the deinitions for shell utility and filter?

0 Answers  


Write a shell script to check whether a number is Armstrong number or not?

1 Answers   Flipkart,


How will I insert a line "abcdef" at every 100th line of a file?

2 Answers  


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

0 Answers  


What is console line?

0 Answers  


Categories