Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
3 replies Latest Post - ‏2007-03-28T17:07:09Z by orphy
SystemAdmin
SystemAdmin
232 Posts
ACCEPTED ANSWER

Pinned topic Simple Linux Scripting

‏2007-03-28T16:10:17Z |
Hello -

I need to write a simple linux script that will unzip a file that is dropped on the same box every day. I'm assuming by create date is the easiest way to do it but don't know how. And advice would be much apprecaited.

thanks
Gary
Updated on 2007-03-28T17:07:09Z at 2007-03-28T17:07:09Z by orphy
  • orphy
    orphy
    2 Posts
    ACCEPTED ANSWER

    Re: Simple Linux Scripting

    ‏2007-03-28T16:27:45Z  in response to SystemAdmin
    Gary,

    You can try something like this but it assumes a few things.

    $ ls -1tr <file>*|tail -1

    If this doesn't fit your need, man ls and search for "time".
    The man page should have everything you need.
    Orphy
    • SystemAdmin
      SystemAdmin
      232 Posts
      ACCEPTED ANSWER

      Re: Simple Linux Scripting

      ‏2007-03-28T16:45:07Z  in response to orphy
      Thanks for your response - but my file name changes every day so I need to find a way to make it unzip regardless of file name, just unzip anything that was created today
      • orphy
        orphy
        2 Posts
        ACCEPTED ANSWER

        Re: Simple Linux Scripting

        ‏2007-03-28T17:07:09Z  in response to SystemAdmin
        This is one possible way to do it.

        DIR=/tmp
        date '+%Y-%m-%d'
        ls --full-time $DIR | grep " $DATE " | awk '{print $9}' | \
        while read file
        do
        unzip $DIR/$file
        done
        Orphy