Select unique records using key

I need to select unique records from a file based on a key in the
file.  For example, the key field is in columns 1-6.

123456ABCD
123457ABCD
123456EFGH

Output file

123456ABCD
123457ABCD

I searched the websites to find some code I could reapply but had no
luck.  Can someone please share some code that would create this
output?
Thanks.
Sandy
0
assum
8/10/2004 1:45:23 PM
comp.unix.programmer 10730 articles. 0 followers. kokososo56 (349) is leader. Post Follow

2 Replies
667 Views

Similar Articles

[PageSpeed] 51
Sandy <assum.sr@pg.com> wrote:
> I need to select unique records from a file based on a key in the
> file.  For example, the key field is in columns 1-6.

> 123456ABCD
> 123457ABCD
> 123456EFGH

> Output file

> 123456ABCD
> 123457ABCD

> I searched the websites to find some code I could reapply but had no
> luck.  Can someone please share some code that would create this
> output?

Sorry, no code, but a simple combination of the 'sort' and 'uniq'
utilities should do the job perfectly well:

sort data_file | uniq -w 6
                                  Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  Jens.Toerring@physik.fu-berlin.de
   \__________________________  http://www.toerring.de
0
Jens
8/10/2004 2:12:53 PM
Sandy wrote:
> I need to select unique records from a file based on a key in the
> file.  For example, the key field is in columns 1-6.
> 
> 123456ABCD
> 123457ABCD
> 123456EFGH
> 
> Output file
> 
> 123456ABCD
> 123457ABCD
> 
> I searched the websites to find some code I could reapply but had no
> luck.  Can someone please share some code that would create this

perl -ne'print unless $seen{ substr $_, 0, 6 }++' yourfile



John
-- 
use Perl;
program
fulfillment
0
John
8/10/2004 6:29:33 PM
Reply:
Similar Artilces:

Writing to REG_MULTI_SZ windows registry keys
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C3ECDC.6AABF380 Content-Type: text/plain Content-Transfer-Encoding: 7bit Hello. I'm looking for any information I can get about writing values to keys in the Windows registry when the value type is a multi-string (ie. REG_MULTI_SZ). When I get the value of a multi-string value using winreg functions, I get a tuple with tuple[0] being a list, and tuple[1] a number. If I try to write such a tuple back into a multi-string value, I ...

Memo Field data truncated using Total button in union query
I am having data from a union query truncate when displayed in a report. All of my data shows in the table, query, and when the query is exported to MS Word, but not when displaying a report from within Access (2000). When I created a union query that didn't have the "Total" button activated (for groupby, sum, etc.) the query worked great and transfers the info into a report without truncating any of the data. Even just the "Totals" button activated but nothing else altered for calculating is enough to cause the info to truncate. Now I am at a loss on how ...

Hide/Show Selection List
I need the capabilty to hide/show a selection list, just the way its done at http://www.lufthansa.com (place the cursor over "Group Companies"). However, I am looking for a javascript that is much simpler. Here is what I have until now. Problems with my code: 1. The selection list becomes invisible when I try to select an option (in Firefox). 2. The selection list stays visible when I just place the cursor over selection list and move the cursor out (without clicking). Please help, Shashi <HTML> <HEAD> <script type="text/javascript"> function showSelect...

using lvmstat for monitoring.
Hello, I have a bottleneck on one of the disks on a LPARed Pseries 670 (AIX 5.2 ML3). I was trying to use topas, lvmstat, vmstat and came with these results. # vmstat 1 10 System Configuration: lcpu=5 mem=8192MB kthr memory page faults cpu ----- ----------- ------------------------ ------------ ----------- r b avm fre re pi po fr sr cy in sy cs us sy id wa 2 2 731794 51375 0 0 1 32 75 0 222 19768 1849 12 7 54 26 2 1 731913 51243 0 0 0 0 0 0 2292 29286 4815 41 15 16 28 3 1 731914 51242 0 0 0 0 0...

Determining if user is using Win98 & MSIE
If a user is using a combination of Win98 & any version of MSIE, I want to display a message. The best that I can do is the following: <? if ((strstr (getenv('HTTP_USER_AGENT'), 'MSIE')) && (strstr (getenv('HTTP_USER_AGENT'), '98'))) { echo"blah,blah,blah\n"; } ?> Is there a better (more foolproof) way? Thanks! - Dazed wrote: > If a user is using a combination of Win98 & any version of MSIE, I > want to display a message. That's not as easy as you think it might be. > The best that I can do is the following: > &...

select in a loop
Hello everyone, I just started with PL/Sql and directly have a problem. I want to iterate in a loop and use an entry in a where-statement of a pretty complex query. I did the following: BEGIN FOR item IN ( SELECT * FROM test ) LOOP select * from (pretty complex subquetries...) where something.id = item.id END LOOP; END; Unfortunately this does not seem to work. Does anybody of you have an idea? Best regards, Alex On Jul 11, 3:40 pm, "alexander.stuckenh...@fernuni-hagen.de" <alexander.stuckenh...@gmail.com> wrote: > Hello ...

Keys on Pismo Keyboard Intermittent
The "L" and "Spacebar" keys on my keyboard are becoming intermittent. Is it possible to remove a keycap and clean the switch contacts? If so, how? -- Ed Fortmiller | RUBBISHef23u@fortmiller.us | Hudson MA * * To avoid getting a lot of SPAM junk mail, I have altered my REPLY-TO * address. PLEASE remove the leading "RUBBISH" from my REPLY address. * Any Email sent to the address without removing "RUBBISH" will * automatically be discarded without me even seeing it. Ed Fortmiller <RUBBISHef23u@fortmiller.us> wrote: > The "L&q...

What would you use? VNC or Exceed?
Hey all, I have a choice of using Exceed or VNC to remotely work on my Linux box.. (I don't have a second monitor..) Are there any pro's/con's to using either? Thanks Dave -- ---- david.best@sympatico.ca "Thanks to the remote control I have the attention span of a gerbil!" "There are 10 types of people in the world. Those who understand binary, and those who don't." Dave Best <david.bestNOSPAM@sympatico.ca> wrote: > I have a choice of using Exceed or VNC to remotely work on my Linux box.. > (I don't have a sec...

Selecting objects
Is it possible get the handle of a graphics object selected in a figure? help gco Laurren Vishal Mahulkar wrote: > > > Is it possible get the handle of a graphics object selected in a > figure? Vishal Mahulkar wrote: > > > Is it possible get the handle of a graphics object selected in a > figure? See the get_line_hand function in FEX <http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9631&objectType=FILE> ...

x86 Server Selection
We're doing some basic research on how corporate customers evaluate Intel/AMD servers. What we're trying to figure out is if vendor characteristics (service, reliability, etc) are more important than system characteristics (feeds & speeds) to real world customers. . We are asking interested enterprise customers to fill out a web survey. The first 300 participants will receive a $10 Amazon.com gift certificate delivered via email (hotmail, gmail, other anonymous accounts are OK). We aren't selling anything, will not convey info to any 3rd party, and will not use the email addres...

Slow response with net use printer
We have an old DOS program that is not going to go away. There are two workstations that each have a OKIDATA dot matrix printer hooked up to it through a USB port. They are identical except station 2 has a HP laser attached to LPT1. Station 1 uses the NET USE command to connect LPT1 to the HP and they both use the same command to connect to their own OKI's through LPT2. On Station 1 whenever they print to their own OKI it takes two to three minutes for the page to print, on station 2 its almost instantaneous. A windows test print on station1 is also instantaneous. Printi...

Use of do loop and Array
Hi, Im trying to generate the following output (num2) num1 num2 5 1 5 1 5 1 3 2 3 2 3 2 3 2 1 3 1 3 2 4 2 4 2 4 4 5 4 5 4 5 I have written the following code but it is not giving me the desired output. There seems to be some logical problem which im not able to understand data abc; input num1 @@; cards; 4 4 4 4 5 5 5 5 5 5 5 2 2 2 2 2 2 1 1 1 3 3 3 3 3 3 3 3 3 3 3 ; run; data abc; set abc; If _n_ = 1 then num2 = 1; run; data array1; array a[0:31] _tempor...

Multiple selection with QT library
Hi, I went into QT mailing list archive but with no luck. I'm trying to achieve the effect of selection with mouse. When you click left mouse on the desktop for example, and keep it pressed and move the mouse a rectangle isdrawed following the mouse. How can I do this with QT library ? -- Bye, Colossus Cpsed, a Linux OpenGL 3D scene editor http://cpsed.sourceforge.net/ ...

Free firewall with selectable port blocking?
Am looking for a free software firewall which can block specified ports (e.g. port 3137). It's for a slow PC running XP and I do not want to slow it down more with HIPS, anti-phishing or other additional functions. Just want a plain but configurable firewall. Any recommendations? I already tried these.... Agnitum Outpost Free has no fine tuning options. I had bad experiences with Zone Alarm in the past long ago. Comodo with HIPS disabled makes the PC run noticably slower. In the past Filseclab didn't block properly. "Anonymous" wrote: >"F...

Which software to use for a webserver Suse 9.1 pro or suse standard server 8
Hello, I have been reading a lot of help files on how to setup a webserver using suse linux os. Both of these manuals tell me that I can use the pro or the standard server 8 software (I know this is a old one) but which one is better. The manual are not the greatest on how to setup a webservers so I was wondering if some knows where on the net I can read a very simple step by step instructions on how to setup a webserver using my suse software. Any help would be appreciated. ...

integration using matlab #3
sir, if i want to get integration as below yt=int(exp(j*w*t)*(1/(a+j*w)-1/(b+j*w)),w,0,wp) all are symbolic constants, i am getting the result as = -1/600*exp(-t*(a+b))*Ei(1,-600*wp*t-a*t)*exp(b*t)+1/600*exp(-t*(a+b))*Ei(1,-600*wp*t-b*t)*exp(a*t)+1/600*exp(-t*(a+b))*Ei(1,-a*t)*exp(b*t)-1/600*exp(-t*(a+b))*Ei(1,-b*t)*exp(a*t) what does Ei(1,..) mean i would be thankful to u, if u clear my problem. thanking you, pradeep pradeep wrote: > sir, > > if i want to get integration as below > yt=int(exp(j*w*t)*(1/(a+j*w)-1/(b+j*w)),w,0,wp) > all are symbolic con...

How do I use this?
Hi can someone please offer advice as how to use LaTex? Thanks, Leon > Leon Noi wrote on [Tue, 07 Dec 2004 14:50:28 GMT] > Hi can someone please offer advice as how to use LaTex? > Go to <http://www.tex.ac.uk/cgi-bin/texfaq2html> and read the information there. > Thanks, wbr, Lukas -- Lukas Ruf | Wanna know anything about raw | <http://www.lpr.ch> | IP? -> <http://www.rawip.org> | eMail Style Guide: <http://www.rawip.org/style.html>| Leon Noi schrieb: > Hi can someone please offer advice as how to use LaTex? The FAQ: http://www.t...

vector selection of a selection
suppose i have a= [1 2 3 4 5 6 7 8 9] somewhere in my code i have for example: a(5:8) is it possible to select the last two elements of a(5:8) in a single statement so something like a(5:8)(end-1:end)?? On 2006-05-18 20:03 kanivan said the following: > suppose i have a=3D [1 2 3 4 5 6 7 8 9] >=20 > somewhere in my code i have for example: > a(5:8) >=20 > is it possible to select the last two elements of a(5:8) in a single > statement so something like a(5:8)(end-1:end)?? No not in general, but you could use an anonymous function (but I don=B4t= =20 really see the point...

Using the new 'ri'
Folks, Many of you know that 'ri' has undergone some change recently. Maybe not Ruby 1.8.1, but from 1.8.2 onwards, 'ri' will be part of every Ruby installation. This is convenient, but you may have to play a part in generating its database. If you are not sure what the latest is in this cool little program, I put up this page to get you started. It only applies to people who are happy to build the Ruby source from CVS at this stage. http://www.rubygarden.org/ruby?NextGenerationRi Gavin Gavin Sinclair wrote: > Many of you know that 'ri' has undergone som...

Re: OT: Propagation of my NS records?
------THDFJOT6TVTPF0EDK6DE1CVJN6J8CT Content-Type: multipart/alternative; boundary="----GVFBK7PNDIIQLBSSY4Q5PLYJ4GPW25" ------GVFBK7PNDIIQLBSSY4Q5PLYJ4GPW25 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 VGhlcmUgaXMgYSBsb3Qgb2YgYXNzdW1lZCBtYWdpYyB3aXRoIEROUy4gSXQgd291bGQgYmUgbmlj ZSBpZiB0aGluZ3Mgd2VyZSBwb3NzaWJsZSBidXQgdGhleSBhcmVuJ3QuCgpUaGluayBmb3IgYSBt b21lbnQuICdJIGNoYW5nZWQgdGhlIElQT0QgYWRkcmVzcyBidXQgbXkgcmVnaXN0cmFyIGlzbid0 IHBpY2tpbmcgaXQgdXAhJyBXZWxsLCBob3cgZG8geW91IGV4cGVjdCB0aGVtIHRvIGlmIHlvdSBk b24ndCB0ZWxsIHRoZW0/IFRoZXkgZG9uJ3...

Matlab 2008a crashed using calllib()
Hello, I loaded and used dll with Matlab2007b. All worked fine. After I tryed the same script in Matlab2008a, it get crashed. With following message: Saving minidump to file C:\Users\joe\AppData\Local\Temp\matlab_crash_dump.5660.0.dmp ------------------------------------------------------------ ------------ Segmentation violation detected at Sat May 10 11:45:13 2008 ------------------------------------------------------------ ------------ Configuration: MATLAB Version: 7.6.0.324 (R2008a) MATLAB License: 161051 Operating System: Microsoft Windows Vis...

Mechanize Select List Help Needed
Hello. I thought that I'd tap into the group to find out if anyone has had this problem with select lists through Mechanize. I am submitting a form that has a multi select list option. When I view the code submitted through Mechanize, it doesn't show that I selected any of my options in the list, but it will show that I checked one of the checkboxes. My select list code is this: search.fields.name('selectList').options[2].select Any ideas? Thanks. -- Posted via http://www.ruby-forum.com/. Any thoughts on where to look for help with my mechanize question? I am on the...

Re: PROC SQL--select DISTINCT #17
Summary: Distinct #iw-value=1 Tom White <tw2@MAIL.COM> wrote SAS does not recognize the distinct function. In other words, I cannot write ..... select(distinct VAR1), distinct(VAR2), distinct(VAR3), ..... quit; To understand why, consider the data X Y ----- 1 1 1 2 Which row would you eliminate to honor DISTINCT X? DISTINCT is a property of the row not the column. In select count(distinct x), count(distinct y) DISTINCT is a property of one column which really involves a special subquery. In other words, the DISTINCTs are distinctly different...

keyboard Function keys callback
Is it possible to define callbacks for keyboard function keys like F1, F2, F3 etc Please reply to this newsgroup. cheers Mz ...

Unable to create Makefile using configure (building extension)
I'm creating an extension for the first time and configure fails with the following error: configure: error: cannot find install-sh or install.sh in tclconfig ./ tclconfig I am able to successfully build Tcl from it source but I don't see an install-sh or install.sh file in either the source area (C:/tcl_src) or the binary area that I downloaded from ActiveState (C:/Tcl). Where should I look for install.sh or install-sh? Thanks, -dean At the cvs respostery at Sourceforge there is a directory called tclconfig with everything you need, copy it kn the root directory of your extension ...