Sponsored Content
Top Forums Shell Programming and Scripting Grep last two lines, calc & adding comments Post 302818823 by Daniel Gate on Sunday 9th of June 2013 12:44:43 PM
Old 06-09-2013
Grep last two lines, calc & adding comments

HTML Code:
.......
06/09/2013|12:00:00 PM|3|26112|40|44032|27419.7|6 1 0 93 |6|1|0|93
06/09/2013|12:30:00 PM|3|26112|40|44032|27491|11 4 0 85 |11|4|0|85

I have "sysperf.out" file containing the lines above.

What I like to have on the output is:

HTML Code:
Node: prod1db  ===> this is the hostname
Date: 06/09/2013 ===> which is the first column

Time: 12:00:00 PM (which is the 2nd column); Paging Space Util: 3% (3rd column); Memory Util: 62.27% (because 27419.7/44032*100); CPU Util: 6% (4th column from right)
Time: 12:30:00 PM (which is the 2nd column); Paging Space Util: 3% (3rd column); Memory Util: 62.43% (because 27419.7/27491*100); CPU Util: 11% (4th column from right)
So, the output will look like:

PHP Code:
Nodeprod1db
Date
06/09/2013

Time
12:00:00 PMPaging Space Util3%; Memory Util62.27%; CPU Util6%
Time12:30:00 PMPaging Space Util3%; Memory Util62.43%; CPU Util11
and then I want to put this on cron and send out e-mail.

Please advise.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep string & next n lines

need help on this. let say i hv 1 file contains as below: STRING Description bla bla bla Description yada yada yada Data bla bla Data yada yada how do i want to display n lines after the string? thanks in advance! (8 Replies)
Discussion started by: ashterix
8 Replies

2. UNIX for Dummies Questions & Answers

How to put the comments to 50 lines, using vi editor?

Hi All, Please let me know how I can put a comment (e.g // or #) to more than 50 lines using vi editor in a .cpp/.sh file. Thanks in advance. (3 Replies)
Discussion started by: artikulkarni
3 Replies

3. UNIX for Advanced & Expert Users

Add Comments to the specifi lines i na file

I have a requirement like below.I need to Comment some lines in a file. File contains following information. { attribute1 attribute2 atrribute3 attribute4 attribute5 attribute6 attribute7 } I have a requirement like some times i need to comment lines 3 to before '}' and some... (1 Reply)
Discussion started by: ukatru
1 Replies

4. Shell Programming and Scripting

grep string & a few lines after

i need to grep a STRING_A & the next few lines after the STRING_A example file: STRING_A yada yada line 1 line 2 STRING_B yada yada line 1 line 2 line 3 STRING_A yada yada line 1 line 2 line 3 line 4 STRING_A yada yada line 1 line 2 line 3 line 4 (7 Replies)
Discussion started by: ashterix
7 Replies

5. Shell Programming and Scripting

Sed script, changing all C-comments to C++-comments

I must write a script to change all C++ like comments: // this is a comment to this one /* this is a comment */ How to do it by sed? With file: #include <cstdio> using namespace std; //one // two int main() { printf("Example"); // three }//four the result should be: (2 Replies)
Discussion started by: black_hawk
2 Replies

6. UNIX for Advanced & Expert Users

grep source code and exclude comments

I often find myself grepping source code for a variable name and many times the name would be present in comment lines that I 'd prefer not to see. Do you guys know any tricks to filter out comments? Example: snippet of the source code /*** * type comment 1 ***/ void ... (7 Replies)
Discussion started by: migurus
7 Replies

7. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

8. UNIX for Dummies Questions & Answers

Remove blank lines and comments from text file

Hi, I am using BASH. How can I remove any lines in a text file that are either blank or begin with a # (ie. comments)? Thanks in advance. Mike (3 Replies)
Discussion started by: msb65
3 Replies

9. Shell Programming and Scripting

Using Grep & find & while read line in a script

Hello people! I would like to create one script following this stage I have one directory with 100 files File001 File002 ... File100 (This is the format of content of the 100 files) 2012/03/10 12:56:50:221875936 1292800448912 12345 0x00 0x04 0 then I have one... (0 Replies)
Discussion started by: Abv_mx81
0 Replies
Mojo::ByteStream(3pm)					User Contributed Perl Documentation				     Mojo::ByteStream(3pm)

NAME
Mojo::ByteStream - ByteStream SYNOPSIS
# Manipulate bytestreams use Mojo::ByteStream; my $stream = Mojo::ByteStream->new('foo_bar_baz'); say $stream->camelize; # Chain methods my $stream = Mojo::ByteStream->new('foo bar baz')->quote; $stream = $stream->unquote->encode('UTF-8')->b64_encode(''); say $stream; # Use the alternative constructor use Mojo::ByteStream 'b'; my $stream = b('foobarbaz')->html_escape; DESCRIPTION
Mojo::ByteStream provides a more friendly API for the bytestream manipulation functions in Mojo::Util. FUNCTIONS
Mojo::ByteStream implements the following functions. "b" my $stream = b('test123'); Construct a new Mojo::ByteStream object. METHODS
Mojo::ByteStream implements the following methods. "new" my $stream = Mojo::ByteStream->new('test123'); Construct a new Mojo::ByteStream object. "b64_decode" $stream = $stream->b64_decode; Alias for "b64_decode" in Mojo::Util. "b64_encode" $stream = $stream->b64_encode; $stream = $stream->b64_encode(" "); Alias for "b64_encode" in Mojo::Util. b('foo bar baz')->b64_encode('')->say; "camelize" $stream = $stream->camelize; Alias for "camelize" in Mojo::Util. "clone" my $stream2 = $stream->clone; Clone bytestream. "decamelize" $stream = $stream->decamelize; Alias for "b64_decamelize" in Mojo::Util. "decode" $stream = $stream->decode; $stream = $stream->decode('iso-8859-1'); Alias for "decode" in Mojo::Util, defaults to "UTF-8". $stream->decode('UTF-16LE')->unquote->trim->say; "encode" $stream = $stream->encode; $stream = $stream->encode('iso-8859-1'); Alias for "encode" in Mojo::Util, defaults to "UTF-8". $stream->trim->quote->encode->say; "hmac_md5_sum" $stream = $stream->hmac_md5_sum('passw0rd'); Alias for "hmac_md5_sum" in Mojo::Util. "hmac_sha1_sum" $stream = $stream->hmac_sha1_sum('passw0rd'); Alias for "hmac_sha1_sum" in Mojo::Util. b('foo bar baz')->hmac_sha1_sum('secr3t')->quote->say; "html_escape" $stream = $stream->html_escape; $stream = $stream->html_escape('^ !#$%(-;=?-~'); Alias for "html_escape" in Mojo::Util. b('<html>')->html_escape->say; "html_unescape" $stream = $stream->html_unescape; Alias for "html_unescape" in Mojo::Util. b('&lt;html&gt;')->html_unescape->url_escape->say; "md5_bytes" $stream = $stream->md5_bytes; Alias for "md5_bytes" in Mojo::Util. "md5_sum" $stream = $stream->md5_sum; Alias for "md5_sum" in Mojo::Util. "punycode_decode" $stream = $stream->punycode_decode; Alias for "punycode_decode" in Mojo::Util. "punycode_encode" $stream = $stream->punycode_encode; Alias for "punycode_encode" in Mojo::Util. "qp_decode" $stream = $stream->qp_decode; Alias for "qp_decode" in Mojo::Util. "qp_encode" $stream = $stream->qp_encode; Alias for "qp_encode" in Mojo::Util. "quote" $stream = $stream->quote; Alias for "quote" in Mojo::Util. "say" $stream->say; $stream->say(*STDERR); Print bytestream to handle or STDOUT and append a newline. "secure_compare" my $success = $stream->secure_compare($string); Alias for "secure_compare" in Mojo::Util. say 'Match!' if b('foo')->secure_compare('foo'); "sha1_bytes" $stream = $stream->sha1_bytes; Alias for "sha1_bytes" in Mojo::Util. "sha1_sum" $stream = $stream->sha1_sum; Alias for "sha1_sum" in Mojo::Util. "size" my $size = $stream->size; Size of bytestream. "split" my $collection = $stream->split(','); Turn bytestream into Mojo::Collection. b('a,b,c')->split(',')->map(sub { $_->quote })->join(" ")->say; "to_string" my $string = $stream->to_string; Stringify bytestream. "trim" $stream = $stream->trim; Alias for "trim" in Mojo::Util. "unquote" $stream = $stream->unquote; Alias for "unquote" in Mojo::Util. "url_escape" $stream = $stream->url_escape; $stream = $stream->url_escape('^A-Za-z0-9-._~'); Alias for "url_escape" in Mojo::Util. b('foo bar baz')->url_escape->say; "url_unescape" $stream = $stream->url_unescape; Alias for "url_unescape" in Mojo::Util. b('%3Chtml%3E')->url_unescape->html_escape->say; "xml_escape" $stream = $stream->xml_escape; Alias for "xml_escape" in Mojo::Util. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::ByteStream(3pm)
All times are GMT -4. The time now is 11:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy