We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32645
    • 377 Posts
    I know this isn’t strictly a Linux/Unix forum, but I hope someone here can help.

    I’m wanting to extract the contents of a zip file. The contents are a single CSV file. The contents (the extracted CSV file) will be moved to a "data" folder.

    I’ve got it working with the following command, but what I’m after is the ability to add a date/time to the filename. But how do I do this?

    # The following does extract the contents, but never adds the date/time to the filename.
    /usr/bin/unzip -a -o /path/to/inbound/traveldata.zip -d data/ > traveldata$(date +"%Y%m%d").csv
    


    I hope someone can help.

    Thanks
      • 32645
      • 377 Posts
      I’ve figured out a solution now.

      /usr/bin/unzip -a -o /path/to/somefolder/zippedfile.zip -d data/`date +"%Y-%m-%d"`
      


      This creates a folder with the date and the contents are the CSV file I require.

      Now all I have to do is read the contents into MySQL and I’m done.