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 check if the previous command was run successfully?
What is scripting used for?
write a shell script to identify the given string is palindrome or not?
17 Answers CTS, HP, IBM, InfoEst, Wipro,
Is shell scripting a programming language?
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.
How will you list only the empty lines in a file (using grep)?
What is bourne shell scripting?
Explain about return code?
What is bash coding?
How Connect to a Database in Shell Programming?
What exactly is a shell?
How do I run a bin bash script?