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
ports(1M)						  System Administration Commands						 ports(1M)

NAME
ports - creates /dev entries and inittab entries for serial lines SYNOPSIS
/usr/sbin/ports [-r rootdir] DESCRIPTION
devfsadm(1M) is now the preferred command for /dev and /devices and should be used instead of ports. The ports command creates symbolic links in the /dev/term and /dev/cua directories to the serial-port character device files in /devices and adds new entries in /etc/inittab for non-system ports found. System-board ports are given single lower-case letters for names (such as a and b) while other ports are named numerically. ports searches the kernel device tree to find the serial devices attached to the system. It also checks /dev/term and /dev/cua to see what symbolic links to serial devices already exist. ports then performs the following: 1. Assigns new numbers (or letters for system-board ports) to ports that are attached to the system but do not have /dev/term and /dev/cua entries. The numbers or letters assigned are the lowest-unused numbers or letters. 2. Removes dangling links: links from /dev/term and /dev/cua pointing to no-longer-existing ports. 3. Creates new /dev/term and /dev/cua links for new serial devices. 4. Invokes sacadm(1M) to make new port monitor entries for the new devices. This is not done automatically for on-board ports; on worksta- tions these ports are often not used for dial-in sessions, so a port-monitor for one of these ports must be created explicitly. If the configuration has not changed, ports exits without doing anything. Notice to Driver Writers ports considers devices with a node type of DDI_NT_SERIAL, DDI_NT_SERIAL_MB, DDI_NT_SERIAL_DO, or DDI_NT_SERIAL_MB_DO to be serial port devices. Devices with one of these node types must create minor device names that obey the following conventions when calling ddi_cre- ate_minor_node(9F). o The minor name for non-system port devices (DDI_NT_SERIAL) consists of an ASCII numeric string, where the first port on the device is named 0, the second named 1, the third named 2, up to the number of ports provided by the device. o The minor name for non-system dialout devices (DDI_NT_SERIAL_DO) is the ASCII numeric port name, concatenated with ,cu. For example, the minor name for the first dialout port on the serial board is 0,cu. o The minor name for system-board port devices (DDI_NT_SERIAL_MB) consists of a string containing a single ASCII lowercase character, where the first port on the device is named a, the second is named b, the third is named c, for all ports on the device (or up through port z). o The minor name for system-board dialout devices (DDI_NT_SERIAL_MB_DO) consists of the lowercase character port name, concatenated with ,cu. For example, the minor name for the first dialout port on the on-board serial device is a,cu. To prevent disks from attempting to automatically generate links for a device, drivers must specify a private node type and refrain from using one of the above node types when calling ddi_create_minor_node(9F). OPTIONS
The following options are supported: -r rootdir Causes ports to presume that the /dev/term, /dev/cua, and /devices directories are found under rootdir, not directly under /. If this argument is specified, sacadm(1M) is not invoked, since it would update terminal administration files under /etc without regard to the rootdir. EXAMPLES
Example 1: Creating the Serial and Dialout Minor Device Nodes The following example creates the serial and dialout minor device nodes from the xkserial driver's attach(9E) function: /* * Create the minor number by combining the instance number * with the port number. */ #define XKNUMPORTS 8 #define XKMINORNUM(i, p) ((i) << 4 | (p)) #define XKMINORNUM_DO(i, p) ((i) << 4 | (p) | 0x80) int xkserialattach(dev_info_t *dip, ddi_attach_cmd_t cmd) { int instance, portnum; char name[8]; /* other stuff in attach... */ instance = ddi_get_instance(dip); for (portnum = 0; portnum < XKNUMPORTS; portnum++) { /* * create the serial port device */ sprintf(name, "%d", portnum); ddi_create_minor_node(dip, name, S_IFCHR, XKMINORNUM(instance, portnum), DDI_NT_SERIAL, 0); /* * create the dialout device */ sprintf(name,"%d,cu", portnum); ddi_create_minor_node(dip, name, S_IFCHR, XKMINORNUM_DO(instance, portnum), DDI_NT_SERIAL_DO, 0); } } Example 2: Installing the xkserial Port Driver on a Sun Fire 4800 The following example installs the xkserial port driver on a Sun Fire 4800 (with the driver controlling the fictional XKSerial 8 port serial board), with these special files in /devices: # ls -l /devices/ssm@0,0/pci@18,700000/pci@1/xkserial@f,800000/ crw-r----- 1 root sys 32, 16 Aug 29 00:02 xkserial@2000:0 crw-r----- 1 root sys 32, 144 Aug 29 00:02 xkserial@2000:0,cu crw-r----- 1 root sys 32, 17 Aug 29 00:02 xkserial@2000:1 crw-r----- 1 root sys 32, 145 Aug 29 00:02 xkserial@2000:1,cu crw-r----- 1 root sys 32, 18 Aug 29 00:02 xkserial@2000:2 crw-r----- 1 root sys 32, 146 Aug 29 00:02 xkserial@2000:2,cu crw-r----- 1 root sys 32, 19 Aug 29 00:02 xkserial@2000:3 crw-r----- 1 root sys 32, 147 Aug 29 00:02 xkserial@2000:3,cu crw-r----- 1 root sys 32, 20 Aug 29 00:02 xkserial@2000:4 crw-r----- 1 root sys 32, 148 Aug 29 00:02 xkserial@2000:4,cu crw-r----- 1 root sys 32, 21 Aug 29 00:02 xkserial@2000:5 crw-r----- 1 root sys 32, 149 Aug 29 00:02 xkserial@2000:5,cu crw-r----- 1 root sys 32, 22 Aug 29 00:02 xkserial@2000:6 crw-r----- 1 root sys 32, 150 Aug 29 00:02 xkserial@2000:6,cu crw-r----- 1 root sys 32, 23 Aug 29 00:02 xkserial@2000:7 crw-r----- 1 root sys 32, 151 Aug 29 00:02 xkserial@2000:7,cu /dev/term contain symbolic links to the serial port device nodes in /devices # ls -l /dev/term /dev/term/0 -> ../../devices/[....]/xkserial@2000:0 /dev/term/1 -> ../../devices/[....]/xkserial@2000:1 /dev/term/2 -> ../../devices/[....]/xkserial@2000:2 /dev/term/3 -> ../../devices/[....]/xkserial@2000:3 /dev/term/4 -> ../../devices/[....]/xkserial@2000:4 /dev/term/5 -> ../../devices/[....]/xkserial@2000:5 /dev/term/6 -> ../../devices/[....]/xkserial@2000:6 /dev/term/7 -> ../../devices/[....]/xkserial@2000:7 and /dev/cua contain symbolic links to the dialout port device nodes in /devices # ls -l /dev/cua /dev/cua/0 -> ../../devices/[....]/xkserial@2000:0,cu /dev/cua/1 -> ../../devices/[....]/xkserial@2000:1,cu /dev/cua/2 -> ../../devices/[....]/xkserial@2000:2,cu /dev/cua/3 -> ../../devices/[....]/xkserial@2000:3,cu /dev/cua/4 -> ../../devices/[....]/xkserial@2000:4,cu /dev/cua/5 -> ../../devices/[....]/xkserial@2000:5,cu /dev/cua/6 -> ../../devices/[....]/xkserial@2000:6,cu /dev/cua/7 -> ../../devices/[....]/xkserial@2000:7,cu FILES
/dev/term/n Logical serial port devices /dev/cua/n Logical dialout port devices /etc/inittab /etc/saf/* ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability | SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
add_drv(1M), devfsadm(1M), drvconfig(1M), pmadm(1M), sacadm(1M), attributes(5), devfs(7FS), attach(9E), ddi_create_minor_node(9F) Writing Device Drivers SunOS 5.10 8 Nov 2002 ports(1M)
All times are GMT -4. The time now is 02:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy