display the contents of /var/log sorted by size in human readable format
时间: 2024-05-10 13:16:49 浏览: 11
You can use the following command to display the contents of /var/log sorted by size in human-readable format:
```
sudo du -ah /var/log | sort -rh | head -n 20
```
This will display the top 20 largest files and directories in /var/log, sorted by size in a human-readable format (e.g. "1.2M" instead of "1324736"). The "-h" flag on the "sort" command tells it to sort by human-readable numbers, and the "-n" flag on the "head" command tells it to display the first 20 lines of output.
相关问题
How to find the "joint" median of 3 sorted lists, in less than linear time?
There is no way to find the joint median of 3 sorted lists in less than linear time (O(n)) because you have to look at every element in the lists to determine the median. However, you can optimize the process by using a modified binary search algorithm.
Here's how:
1. Find the median of the first list. Let's call it m1.
2. Find the median of the second list. Let's call it m2.
3. Find the median of the third list. Let's call it m3.
4. If m1 == m2 == m3, then you have found the joint median. Return m1.
5. If m1 < m2, then discard the first half of the first list and the second half of the second list.
6. If m2 < m1, then discard the second half of the first list and the first half of the second list.
7. Repeat steps 1-6 until you find the joint median.
This modified binary search algorithm reduces the number of comparisons needed to find the joint median compared to a linear search algorithm. However, it still requires O(n) time in the worst-case scenario where all three lists have different medians.
4. How to find the "joint" median of 3 sorted lists, in less than linear time
One way to find the joint median of 3 sorted lists in less than linear time is through the divide and conquer approach.
1. First, find the median of each list.
2. Compare the three medians and find the largest one, let's call it M.
3. Divide each list into two sublists: one sublist of elements smaller than M and another sublist of elements greater than M.
4. Discard the sublists that contain less than n/2 elements, where n is the total number of elements in the original lists.
5. Repeat steps 2-4 with the remaining sublists until only one element is left in each sublist.
6. The remaining elements are the joint median(s) of the three lists.
This approach has a time complexity of O(log n), where n is the total number of elements in the three lists.