Can anyone help me with this Unix script?

Discussion in 'OT Technology' started by CK976, May 5, 2005.

  1. CK976

    CK976 New Member

    Joined:
    Jul 12, 2004
    Messages:
    91
    Likes Received:
    0
    Location:
    NJ
    Write a Shell script named “rmall” to remove all files with the specified name under the specified
    directory tree.

    SYNOPSIS:

    rmall file-name [directory-name]


    The “file-name” denotes the name of the files to be removed.
    If “directory-name” is NOT entered, the current directory is assumed. Only files will be removed.
     
  2. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    I'm failing to see why the built in rm command cannot do what you are asking. Unless this is for a class assignment, in that case, read the sticky.
     
  3. crontab

    crontab (uid = 0)

    Joined:
    Nov 14, 2000
    Messages:
    23,439
    Likes Received:
    11
    change majors
     
  4. col_panic

    col_panic calm like a bomb Moderator

    Joined:
    Sep 19, 2003
    Messages:
    188,160
    Likes Received:
    0
    Location:
    winter haven, fl
    truth
     
  5. Seros

    Seros I have e-tourettes.

    Joined:
    Oct 24, 2001
    Messages:
    6,173
    Likes Received:
    0
    Location:
    East SF Bay Area
    lol

    Code:
    #!/usr/bin/sh
    fileName=$1
    if [ $2 ]; then
       dirName=$2
    else
       dirName=`pwd`
    fi
    
    find $dirName -exec rm {} \;
    
     
  6. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    I thought this at first too, but I think that what he wants to do is delete a file with the same name in an arbitrary number of subdirectories.
     
  7. Aimless

    Aimless Resident drunkey

    Joined:
    Nov 5, 2001
    Messages:
    2,534
    Likes Received:
    0
    Location:
    Wisconsin
    I think what he wants to do is a homework assignment.
     
  8. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Just because he posted the assignment doesn't mean someone has to go and do it for him. One could offer a pointer on how to get started if one was so inclined.
     

Share This Page