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
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 |
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 enable the shell to know what program should be run to interpret the script?
How can the contents of a file inside jar be read without extracting in a shell script?
How do I open a jshell in cmd?
How do you read arguments in a shell program - $1, $2 ..?
What is bash eval?
What is bourne shell scripting?
HOW TO CREATE 10 USERS IN UNIX(HP-UX) USING SHELL SHELL SCRIPT?
What are the different methods available to run a shell script?
Write a command sequence to find the count of each word?
What is Path variable?What is its use?
What command needs to be used to take the backup?
What is meant by $1 in shell script?