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

    No clue about scripting but I need one today if possible.


    I'm failry new to linux and I haven't a clue how to write shell scripts.
    I searched with google, but to no avail....
    I need a basic script and would appreciate if somebody could help me.

    ----start pseudo code----
    Find files older than 3 days in a given directory
    If files older than 3 days exist then move them to another directory2.
    If files in directory2 are older than 30 days then delete them permanentley
    Then out put the script's activity into a log file
    ----end pseudo code---

    I really appreciate the help!

  2. #2
    Just Joined!
    Join Date
    May 2004
    Location
    Pennsylvania
    Posts
    98
    hmm....
    looks suspiciously like a homework question to me

    Read the rules about posting homework questions

    However, i haven't been to these forums in a long time so i'll be nice.
    Take a look at the "find" command, that should help you get started.
    Code:
    man find

  3. #3
    You probably need the cp command as well, try "man cp" for the particulars. Have a read of http://www.cs.hmc.edu/qref/shell_scripting.html as well.

    Tech

  4. $spacer_open
    $spacer_close
  5. #4
    No guys, seriously...
    I have no clue how to even start a script, I'm sure I could edit one to suit my needs but as for homework: I graduated college in '02

    PLEASE HELP!

  6. #5
    Just Joined!
    Join Date
    May 2004
    Location
    Pennsylvania
    Posts
    98
    Quote Originally Posted by hunterhunter
    I have no clue how to even start a script,
    start with the shebang.
    for bourne shells (most common)
    Code:
    #!/bin/sh
    where /bin/sh is the path to the sh executable (on some systems its /usr/bin/sh). You can do a
    Code:
    which sh
    to determine the correct path.

    If we wrote the script for you, you still would have no clue how to do shell scripting. We try to educate here at linuxforums, so we'll help, but you have to do some research on your own to get it to work.

    so far you have:
    a decent tutorial on writing shell scripts.
    hints on what commands to use (though i suggest 'mv' instead of copy based on your description).
    the first line of your script.

    Give it a shot, use the man pages for command options, see what you come up with. If you get stuck come back and get some help.

  7. #6

  8. #7
    Okay, I'll give it a shot but I'm still fairly 'green' when it comes to Linux.... especially shell scripting.

    Thanks though

  9. #8
    Quote Originally Posted by hunterhunter
    Okay, I'll give it a shot but I'm still fairly 'green' when it comes to Linux.... especially shell scripting.

    Thanks though
    A shellscript in its simplest form is just a sequence of commands that you'd otherwise type on the command line to accomplish some task. So you figure out what you want to achieve, put the commands in a script and then use that every time you need to run the task. Obviously it gets more complicated if you need to take the results of some command and use it in following ones, but the important thing is to have a go and learn from what happens. When you get stuck, ask!

Posting Permissions

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