Computer Hope

Software => Computer programming => Topic started by: Sneaky on December 13, 2018, 12:36:05 PM

Title: Need help with a task in terminal
Post 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.
Title: Re: Need help with a task in terminal
Post by: nil on December 13, 2018, 04:49:57 PM
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
Title: Re: Need help with a task in terminal
Post by: Geek-9pm on December 13, 2018, 05:03:00 PM
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.
Title: Re: Need help with a task in terminal
Post by: Sneaky on December 15, 2018, 05:11:18 AM
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..