Question

In: Computer Science

Unix ramdom question. How do you display a list of files in your current directory, sorted...

Unix ramdom question.

How do you display a list of files in your current directory, sorted by file size with the largest files at the top.

Solutions

Expert Solution

You can simply do

ls -lS <folder_name> | grep -v '^d' 

to list all the files in decreasing order of size

-lS, S tells to sort in descending order
Example:

ls -lS ./ | grep -v '^d'

total 45237
-rwxrwxrwx 1 atriax atriax 34262107 Aug 26 14:44 transactions.csv
-rwxrwxrwx 1 atriax atriax 7340032 Sep 8 13:08 NTUSER.DAT
-rwxrwxrwx 1 atriax atriax 1794048 Jan 21 2019 ntuser.dat.LOG2
-rwxrwxrwx 1 atriax atriax 1572864 Jan 21 2019 ntuser.dat.LOG1
-rwxrwxrwx 1 atriax atriax   524288 Jul 11 15:50 NTUSER.DAT{a5e2f1b0-cf93-11e8-b6a1-802bf91bed62}.TMContainer00000000000000000001.regtrans-ms
-rwxrwxrwx 1 atriax atriax   524288 Jan 21 2019 NTUSER.DAT{a5e2f1b0-cf93-11e8-b6a1-802bf91bed62}.TMContainer00000000000000000002.regtrans-ms
-rwxrwxrwx 1 atriax atriax   148956 Sep 8 19:15 Time oriented Data Visulaizations.ipynb
-rwxrwxrwx 1 atriax atriax    65536 Jul 11 15:50 NTUSER.DAT{a5e2f1b0-cf93-11e8-b6a1-802bf91bed62}.TM.blf
-rwxrwxrwx 1 atriax atriax    53319 Jun 3 11:00 4bo0yx7larez5e34
-rwxrwxrwx 1 atriax atriax     8736 Aug 6 14:58 a.out
-rwxrwxrwx 1 atriax atriax     4349 Jun 11 16:41 requirements.txt
-rwxrwxrwx 1 atriax atriax     2713 May 31 17:22 10-powerline-symbols.conf.1
-r-xr-xr-x 1 atriax atriax     2130 Sep 6 10:50 ntuser.pol
-rwxrwxrwx 1 atriax atriax      664 Aug 6 14:57 main.c
-rwxrwxrwx 1 atriax atriax       75 Aug 6 14:50 file.txt
-rwxrwxrwx 1 atriax atriax       47 Sep 7 16:29 data.txt
-rwxrwxrwx 1 atriax atriax       20 Jan 21 2019 ntuser.ini


Related Solutions

List all files and directories in the current directory and store in a variable called malf....
List all files and directories in the current directory and store in a variable called malf. Count how many lines end with your firstname in the file /etc/conf Explain this command: mv pmu*.[ab]   cces/   Quick help in 5 min pleases with the UNIX program! I want only the final answer
Task 1: Getting familiar with Unix commands Questions: How do you remove a directory and all...
Task 1: Getting familiar with Unix commands Questions: How do you remove a directory and all of its contents, including any subdirectories and files, without using rmdir repeatedly?         [5 Points] Go to your home directory (i.e. /home/) and enter the following command: ls -ali Explain the output. You need to clearly what each column specifies, what are the values in each column means. Also explain how it is different from: ls -li    [5 Points] How will you copy directory (not...
Demonstrate your grasp of the Unix file system by constructing a directory structure as follows: In...
Demonstrate your grasp of the Unix file system by constructing a directory structure as follows: In your home ( ~ ) directory, create a directory named “UnixCourse”. This directory will be used in the remaining assignments of this course, as well as this one. Several of the commands that you will issue in this course will examine files in this directory and, in some cases, send me a listing of those files or even copies of those files for grading...
We are interested in the implementation of a Unix/Linux system utility for the concatenation of a list of n text files.
Write in C We are interested in the implementation of a Unix/Linux system utility for the concatenation of a list of n text files. In order to do that we are going to consider the following syntax below where the concatenation of n text files are written in the output file all.txt or on the console if the output text file is not specified.       $./mycat file_1.txt file_2.txt   . . .   file_n.txt > all.txt
how to do circular linked list in c++ (inset and delet and display)
how to do circular linked list in c++ (inset and delet and display)
Question: Write an implementation of the ADT sorted list that uses a resizable array (vector class...
Question: Write an implementation of the ADT sorted list that uses a resizable array (vector class of C++ STL) to represent the list items. Anytime the list becomes full, double the size of the array.
assume a program in unix that have a multiple system calls how to show the list...
assume a program in unix that have a multiple system calls how to show the list of system calls used in the program?
create verilog source files for a seven segment display using the software vivado. show your steps.
create verilog source files for a seven segment display using the software vivado. show your steps.
Lets say that I were to give you a sorted list of P elements that was...
Lets say that I were to give you a sorted list of P elements that was followed by randomly ordered elements. Please explain how you would sort the entire, whole list? Please give a detailed reasoning and provide a good explanation (In language C++) Please type answer if you can
How do you display all the formulas in an Excel spreadsheet? There is a toggle switch...
How do you display all the formulas in an Excel spreadsheet? There is a toggle switch and you start by pressing CTRL and then another character. What is the other character to allow you to display all the formulas in your spreadsheet at once?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT