Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-01-2012
Registered User
 
Join Date: Apr 2012
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Move Command with Adding Yesterday date

How to move a file with mv command by adding yesteday's date(YYYYMMDD) at the end

Example:

/a/abc.txt should be moved to the same folder /a/abc_yyyymmdd.txt

YYYYMMDD should be yesterday's date
Sponsored Links
    #2  
Old 06-01-2012
balajesuri's Avatar
#! /bin/bash
 
Join Date: Apr 2009
Location: India
Posts: 1,565
Thanks: 14
Thanked 440 Times in 425 Posts
With GNU date:

Code:
mv abc.txt abc_$(date -d "-1 day" +%Y%m%d).txt

Sponsored Links
    #3  
Old 06-02-2012
Registered User
 
Join Date: Apr 2012
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Thanks a lot!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help in Shell Script comparing todays date with Yesterday date from Sysdate kumarmsk1331 Shell Programming and Scripting 0 07-29-2011 04:49 PM
Using the find command to copy yesterday date only files Colel2 UNIX Desktop for Dummies Questions & Answers 4 05-28-2009 08:18 PM
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 9 12-01-2008 10:37 PM
yesterday date month/date skully Shell Programming and Scripting 5 06-24-2008 05:51 AM
get yesterday's date? fedora Shell Programming and Scripting 1 12-08-2006 02:28 PM



All times are GMT -4. The time now is 07:51 PM.