Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Need help with a task in terminal  (Read 7215 times)

0 Members and 1 Guest are viewing this topic.

Sneaky

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 10
    Need help with a task in terminal
    « 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.

    nil

    • Global Moderator


    • Intermediate
    • Thanked: 15
      • Experience: Experienced
      • OS: Linux variant
      Re: Need help with a task in terminal
      « Reply #1 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
      Do not communicate by sharing memory; instead, share memory by communicating.

      --Effective Go

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Need help with a task in terminal
      « Reply #2 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.

      Sneaky

        Topic Starter


        Newbie

        • Experience: Beginner
        • OS: Windows 10
        Re: Need help with a task in terminal
        « Reply #3 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..
        « Last Edit: December 15, 2018, 05:41:48 AM by Sneaky »