09-10-2009
Concatenating Files In A Year/Month/Day File Structure
Hi Im trying to concatenate a specific file from each day in a year/month/day folder structure using Bash or equivalent. The file structure ends up like this:
2009/01/01/products
2009/01/02/products
....
2009/12/31/products
The file I need is in products everyday and I need the script to realize when its run out of days and move onto the next month, then realize when its run out of months then move onto the next year, the realize when it runs out of years and stop. Is it be possible to echo what year/month/day its on and have accept input at the start so I could pick what year/month/day it starts?
Any ideas would be greatly appreciated as the boss tasked me with this script and I have no scripting experience.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
i want to delete files that are one day old
condition is files should be of current month only ie if iam running script on 1 march it should not delete files of 28 feb(29 if leap year :-)}
any modifications to
find $DIR -type f -atime +1 -exec rm -f{}\; (4 Replies)
Discussion started by: maverick
4 Replies
2. Shell Programming and Scripting
I have a date that looks like this:
2008/100:18:40:47.040
I need it to look like this:
2008 04 09 18 40 47 040
I have looked at datecalc and it doesn't seem like it takes the day of year for this year (or whatever year is input) and converts it into month and day. It also has to account... (2 Replies)
Discussion started by: ajgwin
2 Replies
3. Shell Programming and Scripting
Dear All,
Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report.
to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for... (2 Replies)
Discussion started by: tiger2000
2 Replies
4. AIX
Hello,
How do I convert unix timestamp value to 'normal' date format - to get year month and day values ?
Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ?
I don't want to write C program, any ways to do that using unix shells ?
thanks (1 Reply)
Discussion started by: vilius
1 Replies
5. Shell Programming and Scripting
Hi
I have files like
abc_cd_20110302_123423
abc_cd_ef_20110301_123423
abc_cd_ef_20110403_123423
abc_ef_20110401_123423
I want to extract the
the year and month associated with each file.
I tried
logfileyearmonth=`echo $logfile | awk -F_'{print $NF}'`
Any other way can I... (6 Replies)
Discussion started by: dgmm
6 Replies
6. Shell Programming and Scripting
hello,
I have many files called day001, day002, day003 and I want to rename them by day20070101, day20070102, etc.
I need to do it for several years and leap years as well.
What is the best way to do it ?
Thank you. (1 Reply)
Discussion started by: Ggg
1 Replies
7. Shell Programming and Scripting
Hi All,
I need to find all files other than first two files dates & last file date for month and month/year wise list.
lets say there are following files in directory
Mar 19 2012 c.txt
Mar 19 2012 cc.txt
Mar 21 2012 d.txt
Mar 22 2012 f.txt
Mar 24 2012 h.txt
Mar 25 2012 w.txt
Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies
8. Shell Programming and Scripting
Hi All,
I find all files for same month and year
lets say there are following files in directory
-rwxr-xr-x 1 user userg 1596 Mar 19 2012 c.txt
-rwxr-xr-x 1 user userg 1596 Mar 21 2012 d.txt
-rwxr-xr-x 1 user userg 1596 Mar 22 2012 f.txt
-rwxr-xr-x 1... (8 Replies)
Discussion started by: Makarand Dodmis
8 Replies
9. Shell Programming and Scripting
how to find all files other than first two dates & last date per month and year
Hi All,
lets say there are following files in directory
-rwxr-xr-x 1 user userg 1596 Mar 19 2012 a.txt
-rwxr-xr-x 1 user userg 1596 Mar 19 2012 b.txt
-rwxr-xr-x 1 user userg ... (6 Replies)
Discussion started by: Makarand Dodmis
6 Replies
10. Shell Programming and Scripting
Hi All,
lets say there are following files in directory
-rwxr-xr-x 1 user userg 1596 Mar 19 2012 a.txt
-rwxr-xr-x 1 user userg 1596 Mar 19 2012 b.txt
-rwxr-xr-x 1 user userg 1596 Mar 22 2012 c.txt
-rwxr-xr-x 1 user userg 1596 Mar 24 2012 d.txt... (16 Replies)
Discussion started by: Makarand Dodmis
16 Replies
GMMKTIME(3) 1 GMMKTIME(3)
gmmktime - Get Unix timestamp for a GMT date
SYNOPSIS
int gmmktime ([int $hour = gmdate("H")], [int $minute = gmdate("i")], [int $second = gmdate("s")], [int $month = gmdate("n")], [int
$day = gmdate("j")], [int $year = gmdate("Y")], [int $is_dst = -1])
DESCRIPTION
Identical to mktime(3) except the passed parameters represents a GMT date. gmmktime(3) internally uses mktime(3) so only times valid in
derived local time can be used.
Like mktime(3), arguments may be left out in order from right to left, with any omitted arguments being set to the current corresponding
GMT value.
PARAMETERS
o $hour
- The number of the hour relative to the start of the day determined by $month, $day and $year. Negative values reference the hour
before midnight of the day in question. Values greater than 23 reference the appropriate hour in the following day(s).
o $minute
- The number of the minute relative to the start of the $hour. Negative values reference the minute in the previous hour. Values
greater than 59 reference the appropriate minute in the following hour(s).
o $second
- The number of seconds relative to the start of the $minute. Negative values reference the second in the previous minute. Values
greater than 59 reference the appropriate second in the following minute(s).
o $month
- The number of the month relative to the end of the previous year. Values 1 to 12 reference the normal calendar months of the
year in question. Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0
is December, -1 is November, etc. Values greater than 12 reference the appropriate month in the following year(s).
o $day
- The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) refer-
ence the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous
month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the
relevant month reference the appropriate day in the following month(s).
o $year
- The year
o $is_dst
- Parameters always represent a GMT date so $is_dst doesn't influence the result.
Note
This parameter has been removed in PHP 7.0.0.
RETURN VALUES
Returns a integer Unix timestamp.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 7.0.0 | |
| | |
| | $is_dst parameter has been removed. |
| | |
| 5.1.0 | |
| | |
| | As of PHP 5.1.0, the $is_dst parameter became |
| | deprecated. As a result, the new timezone han- |
| | dling features should be used instead. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
gmmktime(3) basic example
<?php
// Prints: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", gmmktime(0, 0, 0, 7, 1, 2000));
?>
SEE ALSO
mktime(3), date(3), time(3).
PHP Documentation Group GMMKTIME(3)