Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to extract a portion of text from a log file Post 302280366 by atilano on Monday 26th of January 2009 04:27:02 PM
Old 01-26-2009
How to extract a portion of text from a log file

I am using Unix on Mac OS X 10.5.6.

I am trying to extract the last entry of a log (text) file. As seen below, each log entry looks like the following (date and time change with each log entry):

Quote:
==================== Carbon Copy Cloner (v. 3.1.3): 2009-01-15 01:29:59 -0500 ====================

50 - 60 lines of log entries

and ends with:

================================================================================
I want the script to extract everything quoted above, including the "===" dividers.

Currently the script I use is the following:

Code:
#! /bin/bash 
tail -n 60 /Library/Logs/CCC.log | mail -s "CCC Log" "myemailaddress"

I'm sure there is a more elegant way to extract the text I want so that I can pipe it into the mail command.

Any help you can provide would be greatly appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separate a portion of text file into another file

Hi, I have my input as follows : I have given two entries- From system Mon Aug 1 23:52:47 2005 Source !100000006!: Impact !100000005!: High Status ! 7!: New Last Name+!100000001!: First Name+ !100000003!: ... (4 Replies)
Discussion started by: srikanth_ksv
4 Replies

2. Shell Programming and Scripting

extract a portion of log file

hello, I want to grep the log file according to time and get the portion of log from one particular time to other. I can grep for individual lines by time but how should I print lines continuously from given start time till end till given end time. Appreciate your ideas, Thanks chandra (8 Replies)
Discussion started by: chandra004
8 Replies

3. Shell Programming and Scripting

extract date portion from file

Hi, I have a file where there is a date field (single line variable length file) how to extract just the date portion from it the position of date field may vary anywhere in the line but will always have the format mm-dd-yyyy for eg . xxxxxxxxxxxxxxx09-10-2006xxxxxxxxxxxxxxxxxxxx (5 Replies)
Discussion started by: misenkiser
5 Replies

4. UNIX for Advanced & Expert Users

Grep a portion of the log file

I want to grep a portion of the log file. grepping a particular pattern and including 10 lines before that and after that occurence. grep -n "SomeString Pattern" filename 10 lines before this occurence and 10 lines after that. Please help. Need the simple script not in awk or sed. (9 Replies)
Discussion started by: sainipardeep
9 Replies

5. Shell Programming and Scripting

How to extract a text portion from a file

Can some one help me with shell script to extract a text block between two known strings. The given input file is as below: Name: abs Some tesxt.... Some tesxt.... Some tesxt.... end of text Name: xyz Some tesxt.... Some tesxt.... Some tesxt.... end of text Name: efg Some... (5 Replies)
Discussion started by: ejazs0
5 Replies

6. Shell Programming and Scripting

Extracting a portion of data from a very large tab delimited text file

Hi All I wanted to know how to effectively delete some columns in a large tab delimited file. I have a file that contains 5 columns and almost 100,000 rows 3456 f g t t 3456 g h 456 f h 4567 f g h z 345 f g 567 h j k lThis is a very large data file and tab delimited. I need... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

7. Shell Programming and Scripting

parsing a portion of Data from a text file

Hi All, I need some help to effectively parse out a subset of results from a big results file. Below is an example of the text file. Each block that I need to parse starts with "Output of GENE for sequence file 100.fasta" (next block starts with another number). I have given the portion of... (8 Replies)
Discussion started by: Lucky Ali
8 Replies

8. Shell Programming and Scripting

Extract portion of log info based on specific word

Hi Gurus, I'm using HP-UX B.11.23 operating system. I've been trying to extract a specific wording for example: "A tool used by tp produced warnings" from my below log data, but could not find a way to solve it. My intention is, if the log contain the word: "A tool used by tp produced... (9 Replies)
Discussion started by: superHonda123
9 Replies

9. Shell Programming and Scripting

How to extract portion of a string?

Hi Gurus, Would like to seek some help on how to extract a portion of string from log's output as shown below. Sample of raw data: piece handle=/test123/disk_dump/test123/df0_cntrl_PCPFCI20120404_68498 tag=TAG20120404T180035 comment=NONE piece... (13 Replies)
Discussion started by: superHonda123
13 Replies

10. Shell Programming and Scripting

Extract portion of data

Hi Gurus, I need some help in extracting some of these information and massage it into the desired output as shown below. I need to extract the last row with the header in below sample which is usually the most recent date, for example: 2012-06-01 142356 mb 519 -219406 mb 1 ... (9 Replies)
Discussion started by: superHonda123
9 Replies
kclog(1M)																 kclog(1M)

NAME
kclog - manage kernel configuration log file SYNOPSIS
config] string] type] name] [count] comment DESCRIPTION
is the administrative command for the HP-UX kernel configuration log file. The log file is automatically maintained by all of the kernel configuration commands (and Any change to any kernel configuration gets logged to this log file, which is located at Note that this file is a plain text file which can be viewed and manipulated using standard Unix file management commands; exists simply for convenience in find- ing particular log file entries. Under normal usage, prints the last count entries in the log file. When one of the options is specified, prints the last count entries that match the specified criteria. If count is not specified, it defaults to 1. Options will print all entries matching criteria. If this option is not specified, will only print the last count entries that match the specified criteria. will print only log file entries describing changes to the saved kernel configuration named config. If this option is not specified, will print log file entries describing changes to any saved or running kernel configuration. will not print any entries. Instead, will create a new entry, as if a kernel configuration change had been made, containing the specified comment. This option is only allowed for users with appropriate privileges. will print only log file entries that contain the given string. will print only log file entries that refer to a configuration object (module or tunable) of the given name. will print only log file entries that refer to configuration objects of the specified type: or RETURN VALUE
returns zero for success. It returns non-zero and prints a diagnostic message if an error occurs. EXAMPLES
To see the last three entries in the log: To see the last entry for the tunable To see the last five entries for module changes: To see all entries for module changes: To see the last entry mentioning Aberdeen: WARNINGS
The format of the log file may be changed without notice. Some configuration changes can be made without using the kernel configuration commands. No log file entries are made for such changes. The log file should not be manually edited. Doing so may cause to behave unpredictably. SEE ALSO
kcmodule(1M), kconfig(1M), kctune(1M), kconfig(5). available on kclog(1M)
All times are GMT -4. The time now is 07:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy