Sponsored Content
Top Forums Shell Programming and Scripting perl : searching for month and storing the date and time in an array Post 302695599 by rangarasan on Monday 3rd of September 2012 08:31:56 AM
Old 09-03-2012
perl

Quote:
Originally Posted by giridhar276
Thanks alot Ranga..

Now I am able to get the required data.

Could you please format the query for the below data.
The output should be same..
I need to copy the data and time(Tue Aug 7 03:54:12 2012) to another variable....

Code:
Created By = sumitp
ServerName = dysp001
FirstOccurrence = Tue Aug  7 03:54:12 2012
ServerSerial = 145924222
Summary = DEVICE HAS STOPPED RESPONDING
Customer = TELECOM
Node = mumabcsbp5034.net.adp.com
Severity = Critical

Thanks in advance...

Regards,
GS
Code:
open(FILE,"<filename");

while(<FILE>) {
  my $data=$_;
  chomp($data);
  if($data=~/ aug /i){
      $res=$data;
      $res=~s/.* = (.*)/$1/;
      print "Original:$data\nResult:$res\n";
  }
  # Do your other stuff here with the date and time.
}
close(FILE);

Here I am assuming that the data is in a file called 'filename' and read that file and do other stiff with that date.

Cheers,
Ranga Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed - searching for string and storing in variable

Hi I'm trying to find a way to search a text file for a specific string. I have a file which contains i.p. addresses and port numbers in the following format: 'ip="www.xxx.yyy.zzz"' 'port="xx""' I want to print only the parts between the double quotes for use in seperate variables,... (4 Replies)
Discussion started by: melias
4 Replies

2. Shell Programming and Scripting

perl: storing regex in array variables trouble

hi this is an example of code: use strict; use warnings; open FILE, "/tmp/result_2"; my $regex="\\ Starting program ver. (.*)"; my $res="Program started, version <$1> - OK.\n"; while (<FILE>) { if ($_ =~ /($regex)/) { print "$res"; } } close FILE; This finds $regex and print... (3 Replies)
Discussion started by: xist
3 Replies

3. Shell Programming and Scripting

Searching array of arrays in perl

Suppose there are two arrays of arrays: @A = ( , , , ); @B = ( , , , , ); For each of $A, $A, $A..., I want to find the corresponding one in @B (match the letter, like $A eq $B), and print out both the second item, for example, $A and $B. How can I do this in perl? grep + map? Hope I... (1 Reply)
Discussion started by: zx1106
1 Replies

4. Shell Programming and Scripting

How to find the create time of a file if current date is in next month

Hi All, I want to find the time diffrence between currnt time and "abc.txt" file create time. I have solve that but if the abc.txt file created last month then is there any process to find the difftent? Exp: Create time of abc.txt is "Apr 14 06:48" and currect date is "May 17 23:47".... (1 Reply)
Discussion started by: priyankak
1 Replies

5. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

6. Shell Programming and Scripting

every time user input create array perl

Hi, How to create array every time user input and store user input and display all array print " Enter input " my @input = split(' ', $input) chmop($input = <STDIN>; foreach ($input) { @array= @input; } print @array"\n"; (1 Reply)
Discussion started by: guidely
1 Replies

7. Shell Programming and Scripting

Storing data in perl 2D array

Respected All, Kindly help me out. I have got file listings in a directory like this: -rw-r--r-- 1 root root 115149 2011-11-17 07:15 file1.stat.log -rw-r--r-- 1 root root 115149 2011-11-18 08:15 file2.stat.log -rw-r--r-- 1 root root 115149 2011-11-19 09:15 file3.stat.log -rw-r--r-- 1... (2 Replies)
Discussion started by: teknokid1
2 Replies

8. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

9. Shell Programming and Scripting

Storing the Linux command output to an array in perl script

Hi I am trying to store the output of a command into an array in perl script. I am able to store but the problem is i am unable to print the array line with one line space. i mean i inserted the \n in loop ...but not getting the result. I have written like this #!/usr/bin/perl @a =... (2 Replies)
Discussion started by: kumar85shiv
2 Replies

10. Shell Programming and Scripting

How to add decimal month to some month in sql, php, perl, bash, sh?

Hello, i`m looking for some way to add to some date an partial number of months, for example to 2015y 02m 27d + 2,54m i need to write this script in php or bash or sh or mysql or perl in normal time o unix time i`m asking or there are any simple way to add partial number of month to some... (14 Replies)
Discussion started by: bacarrdy
14 Replies
HTML::FormFu::Filter::CompoundSprintf(3pm)		User Contributed Perl Documentation		HTML::FormFu::Filter::CompoundSprintf(3pm)

NAME
HTML::FormFu::Filter::CompoundSprintf - CompoundSprintf filter SYNOPSIS
--- element: - type: Multi name: date elements: - name: day - name: month - name: year filter: - type: CompoundSprintf sprintf: '%02d-%02d-%04d' # get the compound-value my $date = $form->param_value('date'); DESCRIPTION
For use with a HTML::FormFu::Element::Multi group of fields. Uses a sprintf pattern to join the input from several fields into a single value. METHODS
sprintf Arguments: $string "sprintf" pattern used to join the individually submitted parts. The pattern is passed to the perl-core "sprintf" function. field_order Inherited. See "field_order" in HTML::FormFu::Filter::_Compound for details. --- element: - type: Multi name: date elements: - name: month - name: day - name year filter: - type: CompoundSprintf field_order: - day - month - year AUTHOR
Carl Franks, "cfranks@cpan.org" LICENSE
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-23 HTML::FormFu::Filter::CompoundSprintf(3pm)
All times are GMT -4. The time now is 09:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy