Topic
  • 3 replies
  • Latest Post - ‏2007-03-28T17:07:09Z by orphy
SystemAdmin
SystemAdmin
232 Posts

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

    Re: Simple Linux Scripting

    ‏2007-03-28T16:27:45Z  
    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

    Re: Simple Linux Scripting

    ‏2007-03-28T16:45:07Z  
    • orphy
    • ‏2007-03-28T16:27:45Z
    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
    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

    Re: Simple Linux Scripting

    ‏2007-03-28T17:07:09Z  
    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
    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