07-29-2011
Ok, you do not have GNU date and you have two patterns in your input file. You want that there is only one pattern.
Mon Jul 18 00:32:52 EDT 2011,NULL,UAT # changes to Jul 18 2011,NULL,UAT
Jul 19 2011,NULL,UAT # not changes
Yes?
---------- Post updated at 11:53 AM ---------- Previous update was at 11:49 AM ----------
You don't need and date command if I'm right about pattern but it's just a habit (maybe bad one) to ask about it any time when I see questions about date manipulations.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Plzzzz, tell me some script about this...
What does this mean ?
sed '/^ */s///'
sed '/^/s// /'
and why it's diferent ???
sed '/ */s// /g' and sed 's/ */ /g'. It's all the same ???
Thanks you very much (2 Replies)
Discussion started by: mle
2 Replies
2. Shell Programming and Scripting
$ cat log.txt
Name Age Sex Lcation nfld alias xsd
CC 25 M XYZ asx KK Y
BB 21 F XAS awe SS N
SD 21 M AQW rty SD A
How can I replace the column with header "Lcation" with the column with header "alias" and delete the "alias" column?
so that the final output will become:
Name Age Sex... (10 Replies)
Discussion started by: jkl_jkl
10 Replies
3. Shell Programming and Scripting
Hi, i read couple of threads here on forum, and googled about what bugs me, yet i still can't find solution.
Problem is below.
I need to change this string (with sed if it is possible):
This is message text that is being quoted
to look like this:
This is message text that is being quotedI... (2 Replies)
Discussion started by: angrybb
2 Replies
4. Shell Programming and Scripting
Need help with either sed or awk to acheive the following
file1
-----
In the amazon forest
The bats eat all the time...
mon tue wed they would eat berries
In the tropical forest
The bats eat all the time...
on wed bats eat nuts
In the rain forest
The bats eat all the time...
on... (2 Replies)
Discussion started by: jville
2 Replies
5. Shell Programming and Scripting
Hi,
Kindly need your expertise in this problem.
I have to search and replace data. The problem is, the data is in the same format but slightly different content. What I need is sed commands that can work for those "slightly different content".
input: ... (3 Replies)
Discussion started by: Alvin123
3 Replies
6. Shell Programming and Scripting
Hi,
I have two files master.txt & reference.txt. Sample below
Master.txt
2372,MTS,AP
919848001104,Airtel,DL
0819,MTS,MUM
919849788001,Airtel,AP
1430,Aircel MP,20
Reference.txt
2372,919848701430,46467
919848002372,2372,47195
2372,919849788001,59027
0819,028803,1
0819,029801,1... (2 Replies)
Discussion started by: siramitsharma
2 Replies
7. Shell Programming and Scripting
Hi,I have 2 files master.txt & reference.txt as shown below & i require o/p as mentioned in file 3 using awk but content is not replacing properlymaster.txt:... (15 Replies)
Discussion started by: siramitsharma
15 Replies
8. Shell Programming and Scripting
I need to be able to search for a string in the first column and if that string exists than replace the nth column with "-9.99".
AW12000012012 2.38 1.51 3.01 1.66 0.90 0.91 1.22 0.82 0.57 1.67 2.31 3.63 0.00
AW12000012013 1.52 0.90 1.20 1.34 1.21 0.67 ... (14 Replies)
Discussion started by: ncwxpanther
14 Replies
9. Shell Programming and Scripting
how to search and replace string in column in file with command sed or other
search "INC0000003.in" and replace column 4 = "W"
$ cat file.txt
INC0000001.in|20150120|Y|N|N
INC0000002.in|20150120|Y|N|N
INC0000003.in|20150120|Y|N|N
INC0000004.in|20150120|Y|N|Noutput... (4 Replies)
Discussion started by: ppmanja3
4 Replies
10. Shell Programming and Scripting
I am passing a variable and replace nth value with the variable.
I tried using many options in awk command but unable to ignore the special characters in the output and also unable to pass the actual value.
Input : "1","2","3"
Output : "1","1000","3"
TempVal=`echo 1000`
Cat... (2 Replies)
Discussion started by: onesuri
2 Replies
LEARN ABOUT DEBIAN
cache::historical
Historical(3pm) User Contributed Perl Documentation Historical(3pm)
NAME
Cache::Historical - Cache historical values
SYNOPSIS
use Cache::Historical;
my $cache = Cache::Historical->new();
# Set a key's value on a specific date
$cache->set( $dt, $key, $value );
# Get a key's value on a specific date
my $value = $cache->get( $dt, $key );
# Same as 'get', but if we don't have a value at $dt, but we
# do have values for dates < $dt, return the previous
# historic value.
$cache->get_interpolated( $dt, $key );
DESCRIPTION
Cache::Historical caches historical values by key and date. If you have something like historical stock quotes, for example
2008-01-02 msft 35.22
2008-01-03 msft 35.37
2008-01-04 msft 34.38
2008-01-07 msft 34.61
then you can store them in Cache::Historical like
my $cache = Cache::Historical->new();
my $fmt = DateTime::Format::Strptime->new(
pattern => "%Y-%m-%d");
$cache->set( $fmt->parse_datetime("2008-01-02"), "msft", 35.22 );
$cache->set( $fmt->parse_datetime("2008-01-03"), "msft", 35.37 );
$cache->set( $fmt->parse_datetime("2008-01-04"), "msft", 34.38 );
$cache->set( $fmt->parse_datetime("2008-01-07"), "msft", 34.61 );
and retrieve them later by date:
my $dt = $fmt->parse_datetime("2008-01-03");
# Returns 35.37
my $value = $cache->get( $dt, "msft" );
Even if there's no value available for a given date, but there are historical values that predate the requested date, "get_interpolated()"
will return the next best historical value:
my $dt = $fmt->parse_datetime("2008-01-06");
# Returns undef, no value available for 2008-01-06
my $value = $cache->get( $dt, "msft" );
# Returns 34.48, the value for 2008-01-04, instead.
$value = $cache->get_interpolated( $dt, "msft" );
Methods
new()
Creates the object. Takes the SQLite file to put the date into as an additional parameter:
my $cache = Cache::Historical->new(
sqlite_file => "/tmp/mydata.dat",
);
The SQLite file defaults to
$HOME/.cache-historical/cache-historical.dat
so if you have multiple caches, you need to use different SQLite files.
time_range()
# List the time range for which we have values for $key
my($from, $to) = $cache->time_range( $key );
keys()
# List all keys
my @keys = $cache->keys();
values()
# List all the values we have for $key, sorted by date
# ([$dt, $value], [$dt, $value], ...)
my @results = $cache->values( $key );
clear()
# Remove all values for a specific key
$cache->clear( $key );
# Clear the entire cache
$cache->clear();
last_update()
# Return a DateTime object of the last update of a given key
my $when = $cache->last_update( $key );
since_last_update()
# Return a DateTime::Duration object since the time of the last
# update of a given key.
my $since = $cache->since_last_update( $key );
LEGALESE
Copyright 2007-2011 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under
the same terms as Perl itself.
AUTHOR
2007, Mike Schilli <cpan@perlmeister.com>
perl v5.10.1 2011-04-27 Historical(3pm)