#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    42
    Rep Power
    13

    copy rename file in shell script


    I have a series of log files each named by the date they were created.

    I need to run a shell script that copies the latest file and renames it.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    assuming that no logfile was tampered with, i.e. they have the creation / modification date that corresponds to their names... untested, but should this work:

    mv `ls --sort=date|head -1` newfilename

IMN logo majestic logo threadwatch logo seochat tools logo