Grep & print


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep & print
# 8  
Old 10-11-2008
Quote:
Originally Posted by rubin
I see ..., most likely you're running an old version of awk, maybe you can use a different tool like cut or sed, that might support more bytes in the input line.
Code:
getconf LINE_MAX

will show you the max line size your unix tools can handle. 2048 is common.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print & and \n while replacing with sed/awk?

string="din&esh\nisgood" File.txt: the name is sed "s#\#${string}#g" File.txt Output am getting: the name is dinesh is good Expected output: the name is din&esh\nisgood The input string is dynamic it will be keep on changing am able to handle & by placing \& in the string.. (5 Replies)
Discussion started by: dineshaila
5 Replies

2. UNIX for Dummies Questions & Answers

How to create a print filter that print text & image?

Currently, I have a print filter that takes a text file, that convert it into PCL which then gets to a HP printer. This works. Now I need to embedded a image file within the text file. I'm able to convert the image file into PCL and I can cat both files together to into a single document... (1 Reply)
Discussion started by: chedlee88-1
1 Replies

3. Shell Programming and Scripting

awk question: How to print condition of NR & NF together.

Experts: LINE1 :This is line one The FIRST line of the file. LINE2 :This is line two LINE3 :This is line three with 8 fileds LINE4 :This is line four LINE5 :This is line five LINE6 :This is line six with 8 fileds I want to delete line 1, and then process the file and want to print lines... (2 Replies)
Discussion started by: rveri
2 Replies

4. 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

5. Shell Programming and Scripting

compare & print lines with 2 requirements

1.compare 90 logs >20 print off with correct figure 2.compare latest log i.e ciscoresets_20120314 against all records not just the 90 (as above) and any lines not matching print as: NEW:SYDGRE04,10,9 1 (note this number could be 2 or whatever not necessary 1 it could be 2,3 or even 10... (2 Replies)
Discussion started by: slashbash
2 Replies

6. Shell Programming and Scripting

Find a string using grep & print the line above or below that.

Hi All, Please tell me how can I Find a string using grep & print the line above or below that in solaris? Please share as I am unable to use grep -A or grep -B as it is not working on Solaris. (10 Replies)
Discussion started by: Zaib
10 Replies

7. UNIX for Dummies Questions & Answers

Difference between grep, egrep & grep -i

Hi All, Please i need to know the difference between grep, egrep & grep -i when used to serach through a file. My platform is SunOS 5.9 & i'm using the korn shell. Regards, - divroro12 - (2 Replies)
Discussion started by: divroro12
2 Replies

8. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

9. Shell Programming and Scripting

awk pipes & print

Hi, I need to awk some data from some text files, basic stuff, eg: awk '/phrase/ {print $1,$2,$3}' file Which will print columns 1 to 3 of all lines containing "phrase" But what if I wanted to pipe just one of the columns to a command (in my case a date converter) as in: awk... (4 Replies)
Discussion started by: Jonny2Vests
4 Replies

10. Shell Programming and Scripting

PHP & MySQL: sort desending and print

How do i get php to sort the times in a table and print order desending. eg: in the table i have: 02:60.00 02:70.00 02:20.00 02:50.00 in that order in a table how do i get php & mysql to print... (1 Reply)
Discussion started by: perleo
1 Replies
Login or Register to Ask a Question
Mail::Mbox::MessageParser(3)				User Contributed Perl Documentation			      Mail::Mbox::MessageParser(3)

NAME
Mail::Mbox::MessageParser - A fast and simple mbox folder reader SYNOPSIS
#!/usr/bin/perl use Mail::Mbox::MessageParser; my $file_name = 'mail/saved-mail'; my $file_handle = new FileHandle($file_name); # Set up cache. (Not necessary if enable_cache is false.) Mail::Mbox::MessageParser::SETUP_CACHE( { 'file_name' => '/tmp/cache' } ); my $folder_reader = new Mail::Mbox::MessageParser( { 'file_name' => $file_name, 'file_handle' => $file_handle, 'enable_cache' => 1, 'enable_grep' => 1, } ); die $folder_reader unless ref $folder_reader; # Any newlines or such before the start of the first email my $prologue = $folder_reader->prologue; print $prologue; # This is the main loop. It's executed once for each email while(!$folder_reader->end_of_file()) { my $email = $folder_reader->read_next_email(); print $$email; } DESCRIPTION
This module implements a fast but simple mbox folder reader. One of three implementations (Cache, Grep, Perl) will be used depending on the wishes of the user and the system configuration. The first implementation is a cached-based one which stores email information about mailboxes on the file system. Subsequent accesses will be faster because no analysis of the mailbox will be needed. The second implementation is one based on GNU grep, and is significantly faster than the Perl version for mailboxes which contain very large (10MB) emails. The final implementation is a fast Perl-based one which should always be applicable. The Cache implementation is about 6 times faster than the standard Perl implementation. The Grep implementation is about 4 times faster than the standard Perl implementation. If you have GNU grep, it's best to enable both the Cache and Grep implementations. If the cache information is available, you'll get very fast speeds. Otherwise, you'll take about a 1/3 performance hit when the Grep version is used instead. The overriding requirement for this module is speed. If you wish more sophisticated parsing, use Mail::MboxParser (which is based on this module) or Mail::Box. METHODS AND FUNCTIONS SETUP_CACHE(...) SETUP_CACHE( { 'file_name' => <cache file name> } ); <cache file name> - the file name of the cache Call this function once to set up the cache before creating any parsers. You must provide the location to the cache file. There is no default value. new(...) new( { 'file_name' => <mailbox file name>, 'file_handle' => <mailbox file handle>, 'enable_cache' => <1 or 0>, 'enable_grep' => <1 or 0>, 'force_processing' => <1 or 0>, 'debug' => <1 or 0>, } ); <mailbox file name> - the file name of the mailbox <mailbox file handle> - the already opened file handle for the mailbox <enable_cache> - true to attempt to use the cache implementation <enable_grep> - true to attempt to use the grep implementation <force_processing> - true to force processing of files that look invalid <debug> - true to print some debugging information to STDERR The constructor takes either a file name or a file handle, or both. If the file handle is not defined, Mail::Mbox::MessageParser will attempt to open the file using the file name. You should always pass the file name if you have it, so that the parser can cache the mailbox information. This module will automatically decompress the mailbox as necessary. If a filename is available but the file handle is undef, the module will call either bzip2, or gzip to decompress the file in memory if the filename ends with .tz, .bz2, or .gz, respectively. If the file handle is defined, it will detect the type of compression and apply the correct decompression program. The Cache, Grep, or Perl implementation of the parser will be loaded, whichever is most appropriate. For example, the first time you use caching, there will be no cache. In this case, the grep implementation can be used instead. The cache will be updated in memory as the grep implementation parses the mailbox, and the cache will be written after the program exits. The file name is optional, in which case enable_cache and enable_grep must both be false. force_processing will cause the module to process folders that look to be binary, or whose text data doesn't look like a mailbox. Returns a reference to a Mail::Mbox::MessageParser object on success, and a scalar desribing an error on failure. ("Not a mailbox", "Can't open <filename>: <system error>", "Can't execute <uncompress command> for file <filename>" reset() Reset the filehandle and all internal state. Note that this will not work with filehandles which are streams. If there is enough demand, I may add the ability to store the previously read stream data internally so that reset() will work correctly. endline() Returns " " or " ", depending on the file format. prologue() Returns any newlines or other content at the start of the mailbox prior to the first email. end_of_file() Returns true if the end of the file has been encountered. line_number() Returns the line number for the start of the last email read. number() Returns the number of the last email read. (i.e. The first email will have a number of 1.) length() Returns the length of the last email read. offset() Returns the byte offset of the last email read. read_next_email() Returns a reference to a scalar holding the text of the next email in the mailbox, or undef at the end of the file. BUGS
No known bugs. Contact david@coppit.org for bug reports and suggestions. AUTHOR
David Coppit <david@coppit.org>. LICENSE
This software is distributed under the terms of the GPL. See the file "LICENSE" for more information. HISTORY
This code was originally part of the grepmail distribution. See http://grepmail.sf.net/ for previous versions of grepmail which included early versions of this code. SEE ALSO
Mail::MboxParser, Mail::Box perl v5.12.1 2009-08-09 Mail::Mbox::MessageParser(3)