Sponsored Content
Top Forums Shell Programming and Scripting read lines between search pattern Post 302478589 by gefa on Wednesday 8th of December 2010 10:07:34 AM
Old 12-08-2010
read lines between search pattern

I have a file split something like

01/11/2010:
No of users 100

02/11/2010:
No of users 102

03/11/2010:
No of users 99

...

I want to search the file for a particular date and then extract the following line with the date, something like

02/11/2010 No of users 102

I can grep the date or read the file but now sure how to read the line(s) before the next date?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search file for pattern and grab some lines before pattern

I want to search a file for a string and then if the string is found I need the line that the string is on - but also the previous two lines from the file (that the pattern will not be found in) This is on solaris Can you help? (2 Replies)
Discussion started by: frustrated1
2 Replies

2. UNIX for Dummies Questions & Answers

Print lines between the search pattern

hi, I have a file say x.txt containing xxx 123 bla bla ... you xxx dfk dbf ... me xxx ... ... keeps on.. i need to search for pattern in the line starting xxx in the file. If pattern matched, I need to fetch all the lines till i find next xxx. (17 Replies)
Discussion started by: prsshini
17 Replies

3. Shell Programming and Scripting

Pattern search in multiple lines

Hi, I have to search those statements from the file which starts from "shanky"(only shanky, shanky09 or 09shanky is not allowed) and ends with ");". These two string can be in a same line or different line. And also i have to negate those lines which starts with #. Can any one please give me... (2 Replies)
Discussion started by: shanky09
2 Replies

4. Shell Programming and Scripting

Search for Pattern and Print including Lines in between

Gurus, I have a big file that needs to be sorted out and I cant figure out what to do. The file name is as below: Name: xxxx yyyy nnnn Description: dfffgs sdgsgsf hsfhhs afgghhjdgj fjklllll gsfhfh Updated: jafgadsgg gsg Corrected: date today The file consists of line like these. ... (13 Replies)
Discussion started by: The One
13 Replies

5. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

6. Shell Programming and Scripting

search pattern and read lines

Hi, I have a huge de-limited file which has pattern : 99"9876"2010-11-21 12:51:01"J"MNOPQRS ID# 2-1234-1234-0099-9876-0 "" <<read>> 99"9876"2010-11-21 12:51:01"K"R-EMP# 01234567 (LOGOFF) "" <<read>> 99"9876"2010-11-21 12:51:01"L" *AUTO LOGOFF* ... (3 Replies)
Discussion started by: angie1234
3 Replies

7. Shell Programming and Scripting

How to search for pattern in odd lines?

Hi friends, I am looking for sed command/script that would search for a given fixed pattern on odd lines and then if it matches, prints the matching pattern and the next line. For example, in the example below, i am looking for pattern 0 and 1011 on odd lines. ########## start of example file... (10 Replies)
Discussion started by: kaaliakahn
10 Replies

8. Shell Programming and Scripting

sed search pattern and delete lines

Hello, i have a question. My problem is that i have a file like: TEST JOHN ADAM MICHAEL SEBASTIAN ANDY i want find for MICHAEL and want delete lines like this: TEST (4 Replies)
Discussion started by: eightball
4 Replies

9. Shell Programming and Scripting

Search pattern on logfile and search for day/dates and skip duplicate lines if any

Hi, I've written a script to search for an Oracle ORA- error on a log file, print that line and the .trc file associated with it as well as the dateline of when I assumed the error occured. In most it is the first dateline previous to the error. Unfortunately, this is not a fool proof script.... (2 Replies)
Discussion started by: newbie_01
2 Replies

10. Shell Programming and Scripting

Search Pattern and Print lines in Single Column

Hi Experts I have small query where I request the into a single file Suppose: File1: {Unique entries} AA BB CC DD FileB: AA, 123 AA, 234 AA, 2345 CC, 123 CC, 5678 DD,123 BB, 7890 (5 Replies)
Discussion started by: navkanwal
5 Replies
DOVEADM-FETCH(1)						      Dovecot							  DOVEADM-FETCH(1)

NAME
doveadm-fetch - Fetch partial/full messages or message information SYNOPSIS
doveadm [-Dv] [-f formatter] fetch [-S socket_path] fields search_query doveadm [-Dv] [-f formatter] fetch [-S socket_path] -A fields search_query doveadm [-Dv] [-f formatter] fetch [-S socket_path] -u user fields search_query DESCRIPTION
doveadm fetch can be used to fetch messages' contents and metadata. This can be useful for scripts and for debugging. If you want to fetch messages one at a time, see doveadm-search(1). Important: Please respect your users' privacy. OPTIONS
Global doveadm(1) options: -D Enables verbosity and debug messages. -f formatter Specifies the formatter for formatting the output. Supported formatters are: flow prints each line with key=value pairs. pager prints each key: value pair on its own line and separates records with form feed character (^L). tab prints a table header followed by tab separated value lines. table prints a table header followed by adjusted value lines. -v Enables verbosity, including progress counter. This command uses by default the output formatter pager. Command specific options: -A If the -A option is present, the command will be performed for all users. Using this option in combination with system users from userdb { driver = passwd } is not recommended, because it contains also users with a lower UID than the one configured with the first_valid_uid setting. When the SQL userdb module is used make sure that the iterate_query setting in /etc/dovecot/dovecot-sql.conf.ext matches your data- base layout. When using the LDAP userdb module, make sure that the iterate_attrs and iterate_filter settings in /etc/dovecot/dove- cot-ldap.conf.ext match your LDAP schema. Otherwise doveadm(1) will be unable to iterate over all users. -S socket_path The option's argument is either an absolute path to a local UNIX domain socket, or a hostname and port (hostname:port), in order to connect a remote host via a TCP socket. This allows an administrator to execute doveadm(1) mail commands through the given socket. -u user/mask Run the command only for the given user. It's also possible to use '*' and '?' wildcards (e.g. -u *@example.org). When neither the -A option nor -u user was specified, the command will be executed with the environment of the currently logged in user. ARGUMENTS
fields One or more result field names to display, if the search_query matches any messages. In order to specify multiple fields, enclose them in single or double quotes. Supported fields are: body The body of a message. date.received Date and time of final delivery, when the message was delivered to a user's mailbox for the first time. The internal date and time of the source message, when the message was copied by the IMAP COPY command. The date-time attribute when present, otherwise the current time, when the message was saved by the IMAP APPEND command. date.saved Date and time when the message was saved to mailbox. date.sent Date and time of the message's Date: header. flags A message's IMAP flags, e.g. Seen guid A message's globally unique identifier. hdr The header of the message. imap.body IMAP BODY output of the message (see RFC 3501). imap.bodystructure IMAP BODYSTRUCTURE output of the message (see RFC 3501). imap.envelope IMAP ENVELOPE output of the message (see RFC 3501). mailbox Name of the mailbox, in which the message is stored. The name is in UTF-8. mailbox-guid The globally unique identifier of the mailbox, in which the message is located. pop3.uidl A message's unique (POP3) identifier within a mailbox. seq A message's sequence number in a mailbox. size.physical A message's physical size. size.virtual A message's virtual size, computed with CRLF line terminators. text The entire message (header and body). text.utf8 The entire message (header and body) -- UTF-8 encoded. uid A message's unique (IMAP) identifier in a mailbox. user A message owner's login name. search_query Fetch messages matching this search query. See doveadm-search-query(7) for details. EXAMPLE
This example based on the first example from doveadm-search(1). We are fetching the fields mailbox and date.sent from user bob's mailbox with the guid "3a94c928d66ebe4bda04000015811c6a" for the messages with the UIDs 8, 25 and 45. doveadm fetch -u bob "mailbox date.sent" mailbox-guid 3a94c928d66ebe4bda04000015811c6a uid 8,25,45 mailbox: dovecot/pigeonhole/2.0 date.sent: 2010-01-19 01:17:41 (+0100) ^L mailbox: dovecot/pigeonhole/2.0 date.sent: 2010-01-28 09:38:49 (+0100) ^L mailbox: dovecot/pigeonhole/2.0 date.sent: 2010-03-28 18:41:14 (+0200) ^L REPORTING BUGS
Report bugs, including doveconf -n output, to the Dovecot Mailing List <dovecot@dovecot.org>. Information about reporting bugs is avail- able at: http://dovecot.org/bugreport.html SEE ALSO
doveadm(1), doveadm-search(1), doveadm-search-query(7) Dovecot v2.1 2012-02-13 DOVEADM-FETCH(1)
All times are GMT -4. The time now is 07:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy