Find the answer to your Linux question:
Results 1 to 3 of 3
I have switch config files tftpd into a directory /tftpboot/ files are name as such idf1c-1.20090602.cfg etc..... hostname.todaysdate.cfg I started with a bash script essentially creating a directory with Todays ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Posts
    2

    Script to Move files like this??


    I have switch config files tftpd into a directory /tftpboot/
    files are name as such idf1c-1.20090602.cfg etc.....
    hostname.todaysdate.cfg

    I started with a bash script essentially creating a directory with Todays date and I want to move the config files with todays date in to the correct directory? I'm stuck on the mv cmd/// How can i in the script check in the file name for todays date ??


    Possibly using find . ??
    Thanks

  2. #2
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,133
    To produce the date in that format you can use
    Code:
    date +%Y%m%d
    To do that in another command you can enclose it
    Code:
    mkdir $(date +%Y%m%d)
    mv *$(date +%Y%m%d).cfg $(date +%Y%m%d)/
    Or better, set it in a variable and then have it available
    Code:
    dte=$(date +%Y%m%d)
    mkdir $dte
    mv *"$dte".cfg $dte/

  3. #3
    Just Joined!
    Join Date
    Feb 2007
    Posts
    2
    Dang that's quick...let me check it out..
    Thanks

  4. $spacer_open
    $spacer_close

Posting Permissions

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