Moving files from one directory to another based on 2 date variables
Hi All,
I am currently coding for a requirement(LINUX OS) where I am supposed to move a file (Lets Call it Employee.txt) from Directory A to Directory B based on 2 date fields as below, Quote:
Quote:
Also, I need to write the above dates to a dummy file. (so that the next job can identify the dates/files it should process) Can you pls help me figure out how to do it ? Any help is appreciated. Thanks Much Freddie |
Files move
Code:
mv 2012061*_Employee.txt 2012062*_Employee.txt target_dir For example you could write Code:
echo "Date_Current = 20120620" >new_file You should bookmark & read these http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ |
Thanks Chris for your quick reply.
There is a file named AdhocRun.txt which will contain the following dates, P_BUS_DATE - the latest date P_SUB_DATE - The date until which we need to pull the files from. ie, lets say, P_BUS_DATE = 20120620 P_SUB_DATE = 20120610 These dates will change as & when there is an adhoc processing required. Based on these adhoc dates, we should move the files from Source to destination directory. Hope this is clearer now. Thanks, Freddie |
You can use the date command to give you back the current date, or modify it to give you the dates you want. For example, this will give you todays date:
Code:
$(date +"%Y%m%d") Code:
$(date -d "-1 day" +"%Y%m%d") Code:
#!/bin/bash EDIT: To loop through the last 30 days, add in a for loop: Code:
|
Hi All,
I was able to accomplish the requirement of moving the files from one directory to another using the code below, Quote:
Also, the 2nd requirement as I specified was to write the dates from the filenames into a .done file. Below is how the filenames in output.txt look like Quote:
|
All times are GMT -5. The time now is 04:38 AM. |