Sponsored Content
Top Forums Shell Programming and Scripting [Solved] missing date in unix Post 302707815 by pamu on Sunday 30th of September 2012 03:38:22 AM
Old 09-30-2012
Quote:
Originally Posted by rabindratech
those are not available in my file hence for those date will be 0
---------------
Logic
if date available then display - original...right..?
(for example:Mg_Message_count,07-Aug-12,42)
else display count 0
for example:Mg_Message_count,11-Aug-12,0

---------- Post updated at 12:39 AM ---------- Previous update was at 12:27 AM ----------

Please let me you have any doubt
see this..
Code:
$ cat file
Mg_Message_count,1-Aug-12,46
Mg_Message_count,2-Aug-12,48
Mg_Message_count,3-Aug-12,48
Mg_Message_count,4-Aug-12,48
Mg_Message_count,5-Aug-12,48
Mg_Message_count,6-Aug-12,48
Mg_Message_count,7-Aug-12,42
Mg_Message_count,20-Aug-12,24
Mg_Message_count,21-Aug-12,24
Mg_Message_count,22-Aug-12,24
Mg_Message_count,23-Aug-12,24
Mg_Message_count,24-Aug-12,24
Mg_Message_count,25-Aug-12,24

$ awk -F "[-,]" '{if(a){if(($2-a) > 1){p=$1",";q="-"$3"-"$4",0";a++;for(i=a;i<$2;i++){a++;print p""i""q;}{print}}else{a=$2;print $0}}else{a=$2;print $0}}' file
Mg_Message_count,1-Aug-12,46
Mg_Message_count,2-Aug-12,48
Mg_Message_count,3-Aug-12,48
Mg_Message_count,4-Aug-12,48
Mg_Message_count,5-Aug-12,48
Mg_Message_count,6-Aug-12,48
Mg_Message_count,7-Aug-12,42
Mg_Message_count,8-Aug-12,0
Mg_Message_count,9-Aug-12,0
Mg_Message_count,10-Aug-12,0
Mg_Message_count,11-Aug-12,0
Mg_Message_count,12-Aug-12,0
Mg_Message_count,13-Aug-12,0
Mg_Message_count,14-Aug-12,0
Mg_Message_count,15-Aug-12,0
Mg_Message_count,16-Aug-12,0
Mg_Message_count,17-Aug-12,0
Mg_Message_count,18-Aug-12,0
Mg_Message_count,19-Aug-12,0
Mg_Message_count,20-Aug-12,24
Mg_Message_count,21-Aug-12,24
Mg_Message_count,22-Aug-12,24
Mg_Message_count,23-Aug-12,24
Mg_Message_count,24-Aug-12,24
Mg_Message_count,25-Aug-12,24

small correction in the code.. check above...

let me know if you still have any more conditions..? or you need another output..?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[SOLVED] mysql.sock is missing..

mysql.sock file is missing in /opt/lampp/etc/ is there any backup file available in unix... since without that file .. project is not opening.. reply me as soon as possible ... (19 Replies)
Discussion started by: senkerth
19 Replies

2. UNIX for Advanced & Expert Users

Solved: Missing whatis file from my /usr/shar/lib directory...

My whatis file is missing from my /usr/share/lib directory. I know I can recreate it by using catman -w command. My question is, why do all of my other servers have it and this one doesn't. Maybe due to a recent move of old to new servers and it just wasn't copied over. Unlikely, 'cause all... (0 Replies)
Discussion started by: zixzix01
0 Replies

3. Shell Programming and Scripting

[Solved] line breaks missing when emailed from unix to win

hi i am sending an email from unix to windows platform and using uuencode to attach the plain text files (.txt). But when i read the attached file in notepad the linebreaks are gone. uuencode samplefile.txt samplefile.txt | mail -s "test email" <mailid.com> if i copy paste the... (6 Replies)
Discussion started by: midhun19
6 Replies

4. Shell Programming and Scripting

Missing date

hi team, i have a file contains data as follows F1 file --------------------------- date system name 1-jan-2012 x 1-jan-2012 y 1-jan-2012 x 5-jan-2012 y 3-jan-2012 z 3-jan-2012 z 4-jan-2012 x 4-jan-2012 x ... (13 Replies)
Discussion started by: rabindratech
13 Replies

5. Red Hat

[Solved: Missing A Record] DNS issue

Hi, I have recently built a new DNS server and created a new zone. I use an ESMTP server to handle mail and the new domain has been added to this. I can send mail to gmail and other domain addresses but unable to send it to one particular domain. (DSN:Service Unavailable) DNS... (2 Replies)
Discussion started by: Duffs22
2 Replies

6. Solaris

[solved] Group sysadmin missing

Hello all I recently installed a fresh copy of Solaris. I noticed that /etc/passwd does not contain an entry for sysadmin Group #14. Why isnt it there? Other websites state that by default it should be there ! Help! Regards, Junaid ---------- Post updated at 01:04 AM ----------... (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

7. Shell Programming and Scripting

[Solved] Replace yesterday date with today's date except from the first line

Hello, I have a file like this: 2012112920121130 12345620121130msABowwiqiq 34477420121129amABamauee e7748420121130ehABeheheei in case the content of the file has the date of yesterday within the lines containing pattern AB this should be replaced by the current date. But if I use... (3 Replies)
Discussion started by: Lilu_CK
3 Replies

8. Solaris

[solved]Config/enable_mapping missing, how to add?

Issue resolved by upgrading from solaris 11 to solaris 11.1 I would like to enable network mapping. While using instructions from: https://blogs.oracle.com/VDIpier/entry/solaris_11_changing_the_hostname To change my hostname I noticed I am missing the enable mapping bool. What it should... (0 Replies)
Discussion started by: taltamir
0 Replies

9. Shell Programming and Scripting

Pipe output missing date?

I'd like to have the output from this script piped to a text file that has the date at the beginning of it. For example, my ideal would be something like this $./run_script.sh $ls *.out 2013-Feb-26-output_filename.out Here's the code I'm using. #! /bin/ksh DAT=`date '+%Y-%b-%d'` for... (2 Replies)
Discussion started by: DustinT
2 Replies

10. Shell Programming and Scripting

How to get the missing date and day in a table?

Hi Am using unix Aix Ksh Have Created table called vv and i have inserted two date Select * from vv; Output :- New_date 21/02/2013 24/02/2013 I have tried Using One query but Unsuccessful so far.. SELECT l.new_date + '1 day' as miss from vv as l (7 Replies)
Discussion started by: Venkatesh1
7 Replies
PMAILQ(8)																 PMAILQ(8)

NAME
pmailq - Postfix MAIL Queue manager SYNOPSIS
pmailq [OPTION]... [COMMAND] pmailq --help DESCRIPTION
pmailq parses the output of mailq command from postfix (ie: postqueue -p). It permits to perform some actions on a group of entries in queue (like removing or displaying them in a machine readable format). They are selected by applying filters (wildcards are allowed) on criterias like email address, error message from SMTP server, message size, mail status in queue. COMMANDS
Action to perform on selected entries. list (default command) Show a detailed listing of the selected entries. parse Show a listing of the selected entries in a machine readable format. del Delete (via postsuper -d) the selected entries. OPTIONS
-e PATTERN, --email=PATTERN Select entries in queue with email matching PATTERN (PATTERN accepts wildcards). -m PATTERN, --msg=PATTERN Select entries in queue with error message matching PATTERN (PATTERN accepts wildcards). -l SIZE, --size-lower=SIZE Select entries in queue with size lower than SIZE bytes. -u SIZE, --size-upper=SIZE Select entries in queue with size upper than SIZE bytes. -a Select 'active' entries in queue. -o Select 'on hold' entries in queue. --version Show program's version number and exit. -h, --help Show this help message and exit. EXAMPLES
Example 1: display all the entries in queue sent to an email address matching "*@example.com*" with a size between 3000 and 3200 bytes in a machine readable format: # pmailq -u 3000 -l 3200 -e "*@example.com" parse 7E75214643A4|Fri Aug 31|3154|1|0|edgar@example.com B0BDE146B640|Thu Aug 30|3199|1|0|paul@example.com B587E146B675|Wed Aug 29|3065|0|0|paul@example.com CF3C514656E4|Wed Aug 29|3161|0|0|abuse@example.com / / / queue id date size on hold (or not) active (or not) Example 2: remove all mails in queue not sent because of a connection time out: # pmailq -m "*connection*timed*out" del deleting 00CF514616D3 [OK] deleting 12D911461924 [OK] deleting 269EF1461CA9 [OK] deleting 288DF1461CA0 [OK] deleting 3B3901460F62 [OK] deleting 3AE58147019F [OK] SEE ALSO
postsuper(1) privileged queue operations, postqueue(1) mail queue control AUTHOR
Emmanuel Bouthenot <kolter@openics.org> COPYRIGHT AND LICENSE
Copyright 2007-2011 by Emmanuel Bouthenot <kolter@openics.org> This program is released under the "do What The Fuck you want to Public Licence" Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details. 2011-01-05 PMAILQ(8)
All times are GMT -4. The time now is 01:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy