Question: Intuit OnCampus OA 2026 | 16th march 2026 | Coding Assessment | Complete Solutions & Tips | String Parsing & File Sizes |
0
Entering edit mode

Question: Bash: Maximum Size File

Problem Statement: Given the output of the Unix ls -l command, which includes details like file sizes for multiple files, write a script that identifies and prints the name of the file with the largest size.

Example: Consider the output of the ls -l command as follows:

  • -rw-r--r-- 1 user group 1024 Aug 1 12:00 file1.txt
  • -rw-r--r-- 1 user group 2048 Aug 1 12:00 file2.txt
  • -rw-r--r-- 1 user group 512 Aug 1 12:00 file3.txt

The largest file in this output is file2.txt, so the result should be printed as follows: file2.txt

Function Description: Complete the function find_max_size_file in the editor with the following parameters:

  • string ls_output: a multi-line string containing the output of the Linux ls -l command.

Outputs:

  • string: the name of the file with the maximum size.

Constraints:

  • The total number of lines can be up to 1,000.

Sample Input:

5
-rw-r--r-- 1 user staff 1234 Jul 30 14:22 file1.txt
drwxr-xr-x 3 user staff 102 Jul 31 09:15 Documents
... (remaining lines)
ADD COMMENTlink 7 hours ago Rohit • 30

Login before adding your answer.

Similar Posts
Loading Similar Posts