Computer Hope
Software => Computer programming => Topic started by: Sneaky on December 13, 2018, 12:36:05 PM
-
Hello everyone I'm new here..
So I have a task that I have to create a shell script that displays the files that have zero size in a directory, which it will take as an argument, as well as its empty subdirectories.
I'm pretty confused off this.. Could anyone help me? BTW I have to use only "sort" and "uniq" commands.
-
Are you sure that you can only use "sort" and "uniq"? Those commands will help you work with a list of files, but you still need to generate the list somehow.
You can use the "find" command to list files and directories that match certain criteria, including file size:
https://www.computerhope.com/unix/ufind.htm
specifically the "-size" option should help you out. There are examples at the bottom of the page
-
Which command shell are you using?
The bash shell is very popular and has a wide range of commands. For many Linux systems bash is the default shell.
https://www.computerhope.com/unix/ubash.htm
Maybe that could help.
-
Are you sure that you can only use "sort" and "uniq"? Those commands will help you work with a list of files, but you still need to generate the list somehow.
You can use the "find" command to list files and directories that match certain criteria, including file size:
https://www.computerhope.com/unix/ufind.htm
specifically the "-size" option should help you out. There are examples at the bottom of the page
Actually he recommends us to use those two commands..