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

Unix command lines. A) Assume that your current working directory is NOT the same as your...
Unix command lines. A) Assume that your current working directory is NOT the same as your home directory. Print all file and subdirectory names of your home directory into a file named file2. B) Copy the text from line 11 to line 20 of a given file input.txt and append the copied text at the end of the file output.txt. (Assume that the file input.txt contains more than 20 lines of text contents) C) Count and display the total number...
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...
C++ question: Design and implement your own linked list class to hold a sorted list of...
C++ question: Design and implement your own linked list class to hold a sorted list of integers in ascending order. The class should have member functions for inserting an item in the list, deleting an item from the list, and searching the list for an item. Note: the search function should return the position of the item in the list (first item at position 0) and -1 if not found. In addition, it should have member functions to display the...
Java Chapter 12.29 (Rename files) suppose you have a lot of files in a directory named...
Java Chapter 12.29 (Rename files) suppose you have a lot of files in a directory named Exercisei_j, where i and j are digits. Write a program that pads a 0 before j if j is a single digit. For example, a file named Exercise2_1 in a directory will be renamed to Exercise2_01. In Java, when you pass the symbol * from the command line, it refers to all files in the directory (see Supplement III.V). Use the following command to...
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)
Given a list of 4096 sorted values, about how many comparisons can you expect to be...
Given a list of 4096 sorted values, about how many comparisons can you expect to be performed to look for a value that's not in the list using the bubble sort algorithm?
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT