Sponsored Content
Full Discussion: Grepping Date Variable
Top Forums Shell Programming and Scripting Grepping Date Variable Post 302424756 by ravzter on Wednesday 26th of May 2010 08:25:52 AM
Old 05-26-2010
Actually it was my bad! I'm getting get the results now, however I would like additional format and column; allow me to illustrate.

This pretty much the log:

HTML Code:
05-25-2010 21:45:49 1616 1615 0 0 0 0 0 0 0
05-23-2010 21:55:49 1495 1493 0 0 0 3 0 0 0
05-23-2010 22:05:49 1750 1750 0 0 0 0 0 0 0
05-24-2010 22:15:49 1839 1837 0 0 0 0 1 0 0
05-24-2010 22:25:49 1693 1687 0 0 0 3 1 0 1
05-25-2010 22:35:49 1614 1609 0 0 0 3 4 0 0
05-25-2010 22:45:49 1599 1594 0 0 0 0 3 0 0
I tried using the awk portion of your script, but couldn't get it to work.

HTML Code:
#!/bin/bash
echo "You must type the date in this format ---> MM-DD-YYYY"
read vdate
grep $vdate /log/log.csv |awk -F, '{print $1, $2, $3, $12, $13, $14, $15, $16, $17,$18}' |tee /tmp/bk_$vdate.csv
However now I would like I would like the output to display:
1. Time format instead of 22:35:49 I want just 22:35
2. I would like to insert a percentage column between 3 and 5, please see below for the actual results.
HTML Code:
1               2            3      4     5 6 7 8 9 1011
05-25-2010 22:35:49 1614 1609 0 0 0 3 4 0 0
05-25-2010 22:45:49 1599 1594 0 0 0 0 3 0 0
Actual output without date column
HTML Code:
1        2     3      4       5 6 7 8 9 1011
22:35 1614 1609  96%  0 0 0 3 4 0 0
Percentage Calculation
HTML Code:
$3/($2-$11)
I've been at this all night so I'm gonna try and get some sleep now.
Any help would be appreciated.

Thanks again Bakunin!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grepping a variable

I need to pass a parameter that will then be grepped. I need it to grep /paramater and then have a space so if 123 was passed my grep would be grep '/123 ' sample.log this works fine from the command line but when i try and set it searchThis="/$2 " and then run grep $searchThis... (6 Replies)
Discussion started by: magnia
6 Replies

2. Shell Programming and Scripting

Grepping file and returning passed variable if the value does not exist in file at all.

I have a list of fields that I want to check a file for, returning that field if it not found at all in the file. Is there a way to do a grep -lc and return the passed variable too rather then just the count? I am doing some crappy work-around now but I was not sure how to regrep this for :0 so... (3 Replies)
Discussion started by: personalt
3 Replies

3. Shell Programming and Scripting

Display file date after grepping a string in the file

Hi All, I need to recursively grep several folders for a MAC address and display the results with the date of the file name at the start. Even better would be if the final results were displayed chronologically so the newest file is always at the end. Oldest at the top, regardless of what... (8 Replies)
Discussion started by: quemalr
8 Replies

4. Shell Programming and Scripting

Grepping for variable in brackets

I have a script which reads a number out of a log file. The pertinent line is this: cat /tmp/listofnumbers When I run cat /tmp/listofnumbers what I am seeing is on each line. I am trying to make the script read from that file and grep for a variable like the following line should do: ... (4 Replies)
Discussion started by: newbie2010
4 Replies

5. Shell Programming and Scripting

Grepping the file into a variable after SSH into a server

Hi All, When i am logged into a server , i am able to assign grep value to a variable as follows. VAR=`grep 'Listener stopped' /logs/perf.log` However, when i log out of the server, and try to execute the following command by first SSHing into server, it throws error. $ VAR=`ssh Server... (4 Replies)
Discussion started by: srkmish
4 Replies

6. Shell Programming and Scripting

Convert a date stored in a variable to epoch date

I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date #!/usr/bin/ksh set -x for s in server ; do ssh -T $s <<-EOF from_date="12-Jan-2015 12:02:09" to_date="24-Jan-2015 13:02:09" echo \$from_date echo... (7 Replies)
Discussion started by: raj48
7 Replies

7. Shell Programming and Scripting

How to handle grepping variable data containing wildcards?

I have a lot of files with keywords and unique names. I'm using a shell script to refer to a simple pattern file with comma separated values in order to match on certain keywords. The problem is that I don't understand how to handle the wildcard values when I want to skip over the unique names. ... (5 Replies)
Discussion started by: abercrom
5 Replies

8. Shell Programming and Scripting

Grepping the data between 2 date ranges

Hi There, Good Day !! I have txt file containing data in the below format. There are many lines, here i have mentioned for example. cat remo.txt 2/3/2017 file1 3/4/2016 file2 6/6/2015 file5 1/1/2018 file3 4/3/2014 file4 - - - I need to grep the file names for given date rage... (11 Replies)
Discussion started by: kumar85shiv
11 Replies

9. UNIX for Beginners Questions & Answers

How to replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies

10. UNIX for Beginners Questions & Answers

Grepping for one variable while using awk to parse an associated variable

Im trying to search for a single variable in the first field and from that output use awk to extract out the lines that contain a value less than a value stored in another variable. Both the variables are associated with each other. Any guidance is appreciated. File that contains the... (6 Replies)
Discussion started by: ncwxpanther
6 Replies
HTML::ElementGlob(3pm)					User Contributed Perl Documentation				    HTML::ElementGlob(3pm)

NAME
HTML::ElementGlob - Perl extension for managing HTML::Element based objects as a single object. SYNOPSIS
use HTML::ElementGlob; $element_a = new HTML::Element 'font', color => 'red'; $element_b = new HTML::Element 'font', color => 'blue'; $element_a->push_content('red'); $element_b->push_content('blue'); $p = new HTML::Element 'p'; $p->push_content($element_a, ' and ', $element_b, ' boo hoo hoo'); # Tag type of the glob is not really relevant unless # you plan on seeing the glob as_HTML() $eglob = new HTML::ElementGlob 'p'; $eglob->glob_push_content($element_a, $element_b); # Alter both elements at once $eglob->attr(size => 5); # They still belong to their original parent print $p->as_HTML; DESCRIPTION
HTML::ElementGlob is a managing object for multiple HTML::Element(3) style elements. The children of the glob element retain their original parental elements and have no knowledge of the glob that manipulates them. All methods that do not start with 'glob_' will be passed, sequentially, to all elements contained within the glob element. Methods starting with 'glob_' will operate on the glob itself, rather than being passed to its foster children. For example, $eglob->attr(size => 3) will invoke attr(size => 3) on all children contained by $eglob. $eglob->glob_attr(size => 3), on the other hand, will set the attr attribute on the glob itself. The tag type passed to HTML::Element::Glob is largely irrrelevant as far as how methods are passed to children. However, if you choose to invoke $eglob->as_HTML(), you might want to pick a tag that would sensibly contain the globbed children for debugging or display purposes. The 'glob_*' methods that operate on the glob itself are limited to those available in an HTML::Element(3). All other methods get passed blindly to the globbed children, which can be enhanced elements with arbitrary methods, such as HTML::ElementSuper(3). Element globs can contain other element globs. In such cases, the plain methods will cascade down to the leaf children. 'glob_*' methods, of course, will not be propogated to children globs. You will have to rely on glob_content() to access those glob children and access their 'glob_*' methods directly. REQUIRES
HTML::ElementSuper(3) AUTHOR
Matthew P. Sisk, <sisk@mojotoad.com> COPYRIGHT
Copyright (c) 1998-2010 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
HTML::Element(3), HTML::ElementSuper, HTML::ElementRaw, HTML::Element::Table(3), perl(1). perl v5.10.1 2010-06-09 HTML::ElementGlob(3pm)
All times are GMT -4. The time now is 04:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy