Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Whats wrong with this script?


    Hi there,
    can u tell me whats wrong with this answer?
    Do I need to insert echo lines?

    thanks,


    How to write a bash script that takes the name of a directory as an argument and searches the file hierarchy rooted at that directory for zero length files. Write the names of all zero length files to standard output. If there is no option on the command line, have the script delete the file after displaying its name. An -i option on the command line indicates that the script should ask the user for confirmation before deleting the file.

    $ cat zerdel
    if [ $1 == -i ]
    then
    find $2 -empty -print -exec rm -i {} \;
    else
    find $1 -empty -ok rm -i {} \;
    fi

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    This sounds remarkably like a homework question.

    Homework questions are not allowed on LFDO.

  3. #3
    I think you need a #/bin/bash at the top of your script, also the "==" operator is C not bash, for writing conditions in bash use -eq. You could check out one of the easier tutorials like that on www.shelldorado.com.

    Good Luck
    Johnny

  4. $spacer_open
    $spacer_close
  5. #4
    Quote Originally Posted by johnnytheswede
    I think you need a #/bin/bash at the top of your script, also the "==" operator is C not bash, for writing conditions in bash use -eq. You could check out one of the easier tutorials like that on www.shelldorado.com.
    Why do you think you need a #!/bin/bash at the top? And you should really understand the -eq semantics before telling someone to use it (and is plain wrong in this case). Maybe you should check the tutorials!

Posting Permissions

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