Sponsored Content
Full Discussion: Need help filling in ranges
Top Forums UNIX for Dummies Questions & Answers Need help filling in ranges Post 302483043 by anurag.singh on Thursday 23rd of December 2010 11:06:11 AM
Old 12-23-2010
Assuming that file is sorted..
Code:
awk '{if(!d){a=$1;b=$2;c=$3;getline;}if(a==$1 && c >= $2-1) c=$3; else {for(i=b;i<=c;i++) print a":"i;a=$1;b=$2;c=$3;}d=1;}END{for(i=b;i<=c;i++) print a":"i;}' inputFile

If not sorted..
Code:
cat inputFile | sort -n -k1,1 -k2,2 -k3,3 | awk '{if(!d){a=$1;b=$2;c=$3;getline;}if(a==$1 && c >= $2-1) c=$3; else {for(i=b;i<=c;i++) print a":"i;a=$1;b=$2;c=$3;}d=1;}END{for(i=b;i<=c;i++) print a":"i;}'


Last edited by anurag.singh; 12-23-2010 at 02:15 PM.. Reason: corrected per Scrutinizer's point in post #4
This User Gave Thanks to anurag.singh For This Post:
 

10 More Discussions You Might Find Interesting

1. HP-UX

Valid ranges for uids for HP-UX

Hi , I am using adduser in hp-ux to create users in Hp-ux. i would like to know what are the valid values for uids and gids in hp-ux what are the rannges for the valid uids . How to check what are the used uids in Hp-ux . Thanks Narendra babu C (7 Replies)
Discussion started by: naren_chella
7 Replies

2. Shell Programming and Scripting

date ranges

Hi, Please anyone help to achive this using perl or unix scripting . This is date in my table 20090224,based on the date need to check the files,If file exist for that date then increment by 1 for that date and check till max date 'i.e.20090301 and push those files . files1_20090224... (2 Replies)
Discussion started by: akil
2 Replies

3. Shell Programming and Scripting

Saving ranges using awk

Hi All, Is there a way to save a range in variable for later printing? for example write somthing like this: awk ' /pattern1/,/pattern2/{f=range} /pattern3/{print f} ' I don't know excatly what "range" could be but is there a way to do this? (8 Replies)
Discussion started by: ghoda2_10
8 Replies

4. HP-UX

Help reserving UID ranges?

We have recently merged 2 old systems onto a newer Itanium platform. As part of this work we merged the password files and assigned new UID's beginning from 1000. I have a user add script that admins can use to add a user, however this assigns the next available UIB (in the low 100's) rather than... (3 Replies)
Discussion started by: fulhamfcboy
3 Replies

5. Shell Programming and Scripting

Need Help with function that has multiple ranges

I have a problem that I cant figure out what to do in this function i need it to count multiple ranges like 0 10, 5 10, 1 100. I know that my counter needs to be outside the function and that it needs to be set to the lowest numbered positional parameter but thats were I am having trouble if... (6 Replies)
Discussion started by: Emin_Em
6 Replies

6. UNIX for Dummies Questions & Answers

Problem with ranges of numbers

Good day to everyone! So, let's start :) I have a file with a numbers in some ranges for example: 1 10 49 72 ... and this file need to transform to: 1 2 3 4 (14 Replies)
Discussion started by: shizik
14 Replies

7. Shell Programming and Scripting

Values between ranges

Hi, I have two files file1 chr1_22450_22500 chr2_12300_12350 chr1_34500_34550 file2 11000_13000 15000_19000 33000_44000 If the file 1 ranges fall between file2 ranges then assign the value of file2 in column 2 to file1 output: chr2_12300_12350 11000_13000 chr1_34500_34550 ... (7 Replies)
Discussion started by: Diya123
7 Replies

8. IP Networking

Test for overlapping IP ranges

Greetings folks, I have a rather lengthy list of banned IP ranges in iptables. Initially it was constructed as a rather ad-hoc affair, then later I discovered a site which had IP Block By Country lists, and imported several into iptables. If possible, I'd like to be able to verify if the list... (0 Replies)
Discussion started by: putter1900
0 Replies

9. Shell Programming and Scripting

Print numbers between two number ranges

Hi, I have a list.txt file with number ranges and want to print/save new all.txt file with all the numbers and between the numbers. == list.txt == 65936 65938 65942 && 65943 65945 ... (7 Replies)
Discussion started by: AK47
7 Replies

10. Shell Programming and Scripting

Using awk to get the maximum of a value in two different ranges

Dear Unix gurus, I have sample data organised like this and containing 6 columns (with headers): label c2 c3 c4 c5 c6 where c2 to c6 are numeric values in columns c2 to 6. I am trying to create a simple output in a new file containing 3 columns: label max(c2 c3) max(c4 c5 c6) ... (4 Replies)
Discussion started by: ksennin
4 Replies
ZSTTY(4)						   BSD Kernel Interfaces Manual 						  ZSTTY(4)

NAME
zstty, zsc, zs -- Zilog 8530 Serial Communications Controller (SCC) for RS-232C, RS-422, and RS-423 SYNOPSIS
options PPS_SYNC options PPS_TRAILING_EDGE alpha (DEC 3000) zsc0 at ioasic? offset 0x100000 zsc1 at ioasic? offset 0x180000 zstty0 at zsc0 channel ? # serial ports on B channels zstty2 at zsc1 channel ? # serial ports on B channels lkkbd0 at zsc1 channel ? # keyboard port on A channels vsms0 at zsc0 channel ? # mouse port on A channels cesfic zsc* at mainbus0 zstty* at zsc? channel ? mac68k and macppc zsc0 at obio? zstty* at zsc? channel ? options ZS_TXDMA mipsco zsc0 at obio0 addr 0xbb000000 zstty0 at zsc0 channel 0 zstty1 at zsc0 channel 1 mvme68k zsc* at pcc? ipl 4 zsc* at pcctwo? ipl 4 zstty* at zsc? channel ? news68k zsc0 at hb0 addr 0xe0d40000 ipl 5 vect 64 flags 0x0 # news1700 zsc0 at hb1 addr 0xe1780000 ipl 5 vect 64 flags 0x1 # news1200 zstty0 at zsc0 channel 0 zstty1 at zsc0 channel 1 newsmips zsc0 at hb0 addr 0xbfec0000 level 1 flags 0x0 # on-board zsc1 at hb0 addr 0xb8c40100 level 1 flags 0x1 # expansion board zsc2 at hb0 addr 0xb8c40104 level 1 flags 0x1 zsc0 at ap? zstty0 at zsc0 channel 0 zstty1 at zsc0 channel 1 zstty2 at zsc1 channel 0 zstty3 at zsc1 channel 1 zstty4 at zsc2 channel 0 zstty5 at zsc2 channel 1 next68k zsc0 at intio? ipl 5 #zsc1 at intio? ipl 5 zstty0 at zsc0 channel 0 # ttya zstty1 at zsc0 channel 1 # ttyb sgimips zsc* at hpc0 offset ? zstty* at zsc? channel ? sparc zs0 at mainbus0 # sun4c zs0 at obio0 # sun4m zs0 at obio0 addr 0xf1000000 level 12 # sun4/200 and sun4/300 zs0 at obio0 addr 0x01000000 level 12 # sun4/100 zstty0 at zs0 channel 0 # ttya zstty1 at zs0 channel 1 # ttyb zs1 at mainbus0 # sun4c zs1 at obio0 # sun4m zs1 at obio0 addr 0xf0000000 level 12 # sun4/200 and sun4/300 zs1 at obio0 addr 0x00000000 level 12 # sun4/100 kbd0 at zs1 channel 0 # keyboard ms0 at zs1 channel 1 # mouse zs2 at obio0 addr 0xe0000000 level 12 # sun4/300 zstty2 at zs2 channel 0 # ttyc zstty3 at zs2 channel 1 # ttyd sun2 zs0 at obio0 addr 0x002000 # 2/120, 2/170 zs1 at obmem0 addr 0x780000 # 2/120, 2/170 zs0 at obio0 addr 0x7f2000 # 2/50 zs1 at obio0 addr 0x7f1800 # 2/50 zs2 at mbmem0 addr 0x080800 # 2/120, 2/170 (first sc SCSI) zs3 at mbmem0 addr 0x081000 # 2/120, 2/170 (first sc SCSI) zs4 at mbmem0 addr 0x084800 # 2/120, 2/170 (second sc SCSI) zs5 at mbmem0 addr 0x085000 # 2/120, 2/170 (second sc SCSI) zstty* at zs? channel ? # ttya kbd0 at zstty? # keyboard ms0 at zstty? # mouse sun3 zstty0 at zsc1 channel 0 # ttya zstty1 at zsc1 channel 1 # ttyb kbd0 at zsc0 channel 0 # keyboard ms0 at zsc0 channel 1 # mouse x68k zsc0 at intio0 addr 0xe98000 intr 112 zstty0 at zsc0 channel 0 # built-in RS-232C ms0 at zsc0 channel 1 # standard mouse #zsc1 at intio0 addr 0xeafc00 intr 113 #zstty2 at zsc1 channel 0 #zstty3 at zsc1 channel 1 #zsc2 at intio0 addr 0xeafc10 intr 114 #zstty4 at zsc2 channel 0 #zstty5 at zsc2 channel 1 DESCRIPTION
The zstty driver provides TTY support for Zilog 8530 Dual UART chips. Input and output for each line may set to any baud rate in the range 50 to 38400 (and higher on some machines). The PPS_SYNC option enables code to use the Data Carrier Detect (DCD) signal line for attachment to an external precision clock source (e.g., GPS, CDMA) which generates a Pulse Per Second (PPS) signal. This is used by ntpd(8) to discipline the system clock, and more accurately count/measure time. See options(4) for more discussion. FILES
alpha /dev/ttyB0 /dev/ttyB1 others /dev/ttya /dev/ttyb DIAGNOSTICS
zs0*: fifo overflow The on-chip ``FIFO'' has overflowed and incoming data has been lost. This generally means the machine is not responding to inter- rupts from the ZS chip fast enough, which can be remedied only by using a lower baud rate. zs0*: ring overflow The software input "ring" has overflowed. This usually means input flow-control is not configured correctly (i.e. incorrect cable wiring). SEE ALSO
kbd(4), ms(4), options(4), scc(4), tty(4), ntpd(8) HISTORY
The zstty driver was derived from the sparc zs driver supplied with 4.4BSD UNIX. CAVEATS
/dev/ttyB1 on alpha is created by MAKEDEV(8) with minor number 2, so the corresponding device should be zstty2, not zstty1. BUGS
The old Zilog 8530 chip has a very small FIFO (3 bytes?) and therefore has very strict latency requirements for the interrupt service rou- tine. This limits the usable baud rates on many machines. BSD
June 7, 2011 BSD
All times are GMT -4. The time now is 04:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy