Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: share me to do this.

  1. #21
    Join Date
    May 2011
    Beans
    25

    Re: share me to do this.

    ok thanks you

  2. #22
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: share me to do this.

    Quote Originally Posted by matt_symes View Post
    Hi

    Make sure it is executable. chmod 755 <file_name>

    Code:
    #!/bin/bash
    
    : <<"COMMENT"
    
    2. Write a script that takes exactly one argument, a directory name. If the number of arguments is more
    or less than one, print a usage message. If the argument is not a directory, print another message. For
    the given directory, print the five biggest files and the five files that were most recently modified.
    
    COMMENT
    
    # First check the number of parameters passed to the script is 1.
    [[ $# -eq 1 ]] || { echo "Number of parameters is not equal to one"; exit 1; }
    
    # Check to see if the directory exists.
    [[ ! -d "$1" ]] && { echo "The directory $1 does not exist"; exit 1; }
    
    find * -maxdepth 0 -type f -printf "%s %f\n" | sort -nr | cut -d' ' -f 2 | head -n5
    The here-document comment is pretty cool. I never saw it before. Of course, one should avoid it for many reasons, you know, compatibility, portability, etc... But still, it is cool!

    Oh, and, warnings and errors should be redirected to stderr
    Code:
    false || { echo nay; } >&2

  3. #23
    Join Date
    May 2010
    Location
    Tewkesbury uk
    Beans
    7,667
    Distro
    Ubuntu Development Release

    Re: share me to do this.

    Hi

    Quote Originally Posted by sisco311 View Post
    The here-document comment is pretty cool. I never saw it before. Of course, one should avoid it for many reasons, you know, compatibility, portability, etc... But still, it is cool!

    Oh, and, warnings and errors should be redirected to stderr
    Code:
    false || { echo nay; } >&2
    You have raised some good points Sisco, especially the compatibility and portability issues, hence (as you know) the issues the OP was having when using sh and not bash.

    It was written for newer versions of bash and specifically Ubuntu.

    A note to the OP. As you learn more shell scripting you will discover what is portable and what is not portable. As you are learning on Ubuntu it does not matter so much at the moment, but it is something to keep in mind.

    Kind regards
    Join us on irc at #ubuntuforums. For web chat see here

    If you believe everything you read, you better not read. ~ Japanese Proverb

    Do not read newspapers on an empty stomach ~ Russian Proverb ~ BrunoLotse

  4. #24
    Join Date
    May 2011
    Beans
    3

    Re: share me to do this.

    Quote Originally Posted by Come TO love View Post
    I found this book ood book for learn
    and i try solve this Qu in page 28

    hi dear i want as about this book .What is the name of book

    and when i try to solve this quastion i have error can any one help me pleas??

  5. #25
    Join Date
    May 2011
    Beans
    3

    Re: share me to do this.

    please can eny one help my i dont understan this quastion

  6. #26
    Join Date
    May 2011
    Beans
    3

    Re: share me to do this.

    :ks:ks:ks

  7. #27
    Join Date
    May 2010
    Location
    Tewkesbury uk
    Beans
    7,667
    Distro
    Ubuntu Development Release

    Re: share me to do this.

    Hi

    Quote Originally Posted by Sohar-uni View Post
    hi dear i want as about this book .What is the name of book
    The book was linked in post #2

    and when i try to solve this quastion i have error can any one help me pleas??
    What errors are you getting ? Post the back here.

    Kind regards
    Join us on irc at #ubuntuforums. For web chat see here

    If you believe everything you read, you better not read. ~ Japanese Proverb

    Do not read newspapers on an empty stomach ~ Russian Proverb ~ BrunoLotse

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •