Sponsored Content
Top Forums Shell Programming and Scripting Shell Scripting: Copy Files with Today's date Post 302736013 by smkremer on Monday 26th of November 2012 02:35:27 PM
Old 11-26-2012
Shell Scripting: Copy Files with Today's date

I was wondering the best way about finding files that were created today and copy them to a directory (grep ?). There can be multiple files for todays date or none. I am looking to copy all of the .lis files for todays date. I may need to modify the filename to include todays date but for the time being I just want to find the files that were created today and copy them to a directory.

Data:
Code:
-rw-rw-rw-   1 user  user     1697 Nov 24 09:57 file_8885724.lis
-rw-rw-rw-   1 user  user      103 Nov 24 09:57 file_8885724.log
-rw-rw-rw-   1 user  user     1696 Nov 25 09:58 file_8885728.lis
-rw-rw-rw-   1 user  user      537 Nov 25 09:58 file_8885728.log
-rw-rw-rw-   1 user  user     1700 Nov 25 09:58 file_8885730.lis
-rw-rw-rw-   1 user  user     2663 Nov 25 09:58 file_8885730.log
-rw-rw-rw-   1 user  user     1700 Nov 25 09:59 file_8885731.lis
-rw-rw-rw-   1 user  user      967 Nov 25 09:59 file_8885731.log
-rw-rw-rw-   1 user  user     1700 Nov 25 09:59 file_8885732.lis
-rw-rw-rw-   1 user  user     1817 Nov 25 10:00 file_8885732.log
-rw-rw-rw-   1 user  user     1700 Nov 26 10:00 file_8885739.lis
-rw-rw-rw-   1 user  user      529 Nov 26 10:00 file_8885739.log
-rw-rw-rw-   1 user  user     1693 Nov 26 10:00 file_8885743.lis
-rw-rw-rw-   1 user  user      103 Nov 26 10:00 file_8885743.log
-rw-rw-rw-   1 user  user     1697 Nov 26 10:01 file_8885744.lis
-rw-rw-rw-   1 user  user      103 Nov 26 10:01 file_8885744.log
-rw-rw-rw-   1 user  user     1697 Nov 26 10:01 file_8885751.lis
-rw-rw-rw-   1 user  user      103 Nov 26 10:01 file_8885751.log

Script:
Code:
#!/bin/bash
#copy files
cd $1
#I need a loop that will copy the files with todays date
scp $2 $3
#end of loop

Any help would be appreciated. Also, if you provide working code then that would be even better.

Last edited by Scott; 11-27-2012 at 11:34 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sort files by date, not showing files from today

Hi all, i'm new here in this forum. I really like the helpful answers in this forum. Here a short question. For a script i have to sort files by date and exclude the files of the actual date. Sorting the files by date and preparing the output for awk is done by this line: ls -l... (3 Replies)
Discussion started by: carlosdivega
3 Replies

2. Shell Programming and Scripting

Script to copy log files with today's date

I am a newbie to scripting. I need a korn shell script to copy log files of current day to archive folder and rename with current days date stamp. I would really appreciate your help. File structure is as follows. Everyday files get overwritten, so I need copy to a archive directory and... (3 Replies)
Discussion started by: mdncan
3 Replies

3. Shell Programming and Scripting

Past date display ( today - N) in shell

Hi, Any idea to get display of date - n ( n=1,2,3,4 etc) ? For example , dtoudt will easily execute by dtoudt -3 and result is >dtoudt -3 1234852529 Date 2009-2-17 time 14:35:29 day 47 How to get it display in 20090217 instead ? Maybe you have other suggestion to display date... (0 Replies)
Discussion started by: rauphelhunter
0 Replies

4. UNIX for Dummies Questions & Answers

Shell Scripts - shows today’s date and time in a better format than ‘date’ (Uses positional paramete

Hello, I am trying to show today's date and time in a better format than ‘date' (Using positional parameters). I found a command mktime and am wondering if this is the best command to use or will this also show me the time elapse since 1/30/70? Any help would be greatly appreciated, Thanks... (3 Replies)
Discussion started by: citizencro
3 Replies

5. Shell Programming and Scripting

Move all files except sys date (today) files in Solaris 10

I want to move all files from one directory to another directory excluding today (sysdate files) on daily basis. file name is in pattern file_2013031801, file_2013031802 etc (2 Replies)
Discussion started by: khattak
2 Replies

6. Shell Programming and Scripting

ksh shell scripting to copy a file

Hi. I am a new Unix admin and I've been tasked to write a ksh script that copies my .profile into my /home directory on all servers. I'm new to this and having a difficult time scripting it. Any ideas? (6 Replies)
Discussion started by: david_tech
6 Replies

7. Shell Programming and Scripting

Search files with today date and files come anytime in between 10 pm to 1 am

Hi, i want to make script. In a directory everyday( exclude sat and sun) in between 10 pm to 1 am there are 2 files comes and when file comes it will mail us. Format for files is mentioned below. please help me on making this, and also have year end consider and if files come after 12 am it... (6 Replies)
Discussion started by: pallvi_mahajan
6 Replies

8. Shell Programming and Scripting

Problem scripting a copy and renaming shell executable

I also posted this on macrumors forum, then i realized that this is a more suitable forum for matters like this. I apologize for the username, I was looking at a bag of doritos when it asked me for a username. lol I need a program (see below for what I've tried) and I think a shell program will... (23 Replies)
Discussion started by: ilovedoritos
23 Replies

9. UNIX for Beginners Questions & Answers

Find and copy .zip file based on today's date

Hi Team, I'm new to unix and i have a requirement to copy or move files from one directory to another based on current date mentioned in the .zip file name. Note that i need to copy only the recent zip file. please help me with the code i tried the code as: #! /usr/bin/sh find... (3 Replies)
Discussion started by: midhun3108
3 Replies

10. UNIX for Beginners Questions & Answers

Compare Date to today's date in shell script

Hi Community! Following on from this code in another thread: #!/bin/bash file_string=`/bin/cat date.txt | /usr/bin/awk '{print $5,$4,$7,$6,$8}'` file_date=`/bin/date -d "$file_string"` file_epoch=`/bin/date -d "$file_string" +%s` now_epoch=`/bin/date +%s` if then #let... (2 Replies)
Discussion started by: Greenage
2 Replies
curl_getdate(3) 						  libcurl Manual						   curl_getdate(3)

NAME
curl_getdate - Convert a date string to number of seconds since January 1, 1970 SYNOPSIS
#include <curl/curl.h> time_t curl_getdate(char *datestring, time_t *now ); DESCRIPTION
This function returns the number of seconds since January 1st 1970 in the UTC time zone, for the date and time that the datestring parame- ter specifies. The now parameter is not used, pass a NULL there. NOTE: This function was rewritten for the 7.12.2 release and this documentation covers the functionality of the new one. The new one is not feature-complete with the old one, but most of the formats supported by the new one was supported by the old too. PARSING DATES AND TIMES
A "date" is a string containing several items separated by whitespace. The order of the items is immaterial. A date string may contain many flavors of items: calendar date items Can be specified several ways. Month names can only be three-letter english abbreviations, numbers can be zero-prefixed and the year may use 2 or 4 digits. Examples: 06 Nov 1994, 06-Nov-94 and Nov-94 6. time of the day items This string specifies the time on a given day. You must specify it with 6 digits with two colons: HH:MM:SS. To not include the time in a date string, will make the function assume 00:00:00. Example: 18:19:21. time zone items Specifies international time zone. There are a few acronyms supported, but in general you should instead use the specific relative time compared to UTC. Supported formats include: -1200, MST, +0100. day of the week items Specifies a day of the week. Days of the week may be spelled out in full (using english): `Sunday', `Monday', etc or they may be abbreviated to their first three letters. This is usually not info that adds anything. pure numbers If a decimal number of the form YYYYMMDD appears, then YYYY is read as the year, MM as the month number and DD as the day of the month, for the specified calendar date. EXAMPLES
Sun, 06 Nov 1994 08:49:37 GMT Sunday, 06-Nov-94 08:49:37 GMT Sun Nov 6 08:49:37 1994 06 Nov 1994 08:49:37 GMT 06-Nov-94 08:49:37 GMT Nov 6 08:49:37 1994 06 Nov 1994 08:49:37 06-Nov-94 08:49:37 1994 Nov 6 08:49:37 GMT 08:49:37 06-Nov-94 Sunday 94 6 Nov 08:49:37 1994 Nov 6 06-Nov-94 Sun Nov 6 94 1994.Nov.6 Sun/Nov/6/94/GMT Sun, 06 Nov 1994 08:49:37 CET 06 Nov 1994 08:49:37 EST Sun, 12 Sep 2004 15:05:58 -0700 Sat, 11 Sep 2004 21:32:11 +0200 20040912 15:05:58 -0700 20040911 +0200 STANDARDS
This parser was written to handle date formats specified in RFC 822 (including the update in RFC 1123) using time zone name or time zone delta and RFC 850 (obsoleted by RFC 1036) and ANSI C's asctime() format. These formats are the only ones RFC2616 says HTTP applications may use. RETURN VALUE
This function returns -1 when it fails to parse the date string. Otherwise it returns the number of seconds as described. If the year is larger than 2037 on systems with 32 bit time_t, this function will return 0x7fffffff (since that is the largest possible signed 32 bit number). Having a 64 bit time_t is not a guarantee that dates beyond 03:14:07 UTC, January 19, 2038 will work fine. On systems with a 64 bit time_t but with a crippled mktime(), curl_getdate will return -1 in this case. REWRITE
The former version of this function was built with yacc and was not only very large, it was also never quite understood and it wasn't pos- sible to build with non-GNU tools since only GNU Bison could make it thread-safe! The rewrite was done for 7.12.2. The new one is much smaller and uses simpler code. libcurl 7.0 12 Aug 2005 curl_getdate(3)
All times are GMT -4. The time now is 06:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy