Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [Solved] How to extract single and duplicate lines from file? Post 302861605 by Lokaps on Wednesday 9th of October 2013 08:35:46 AM
Old 10-09-2013
[Solved] How to extract single and duplicate lines from file?

Hi,

I need help!

I have two files, one containing a list of codes and the other a list of codes and their meaning. I need to extract from file 2 all the codes from file 1 into a new file.

These are my files:

File1:
Code:
Metbo
Metbo
Memar
Mth
Metbo

File2:
Code:
Metbo Methanoculleus
Memar Methanobacterium
Mth Methanoregula
CLOS Clostridium
PS Pseudomona

Output file should be like:
Code:
Metbo Methanoculleus
Metbo Methanoculleus
Memar Methanobacterium
Mth Methanoregula
Metbo Methanoculleus

I tried with grep -f file1 file2 > outfile

But in the outfile I only get one hit from Metbo and not 3.

Any suggestions.

Thanks in advanced Smilie

Last edited by vbe; 10-09-2013 at 09:56 AM.. Reason: code tags next time please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

tar: extract single file to different filepath

Hi, This is my first post here - I'm hoping I can get some help! I have searched these forums and othersand not getting anything that works. I am trying to extract a single file from a tar archive to a diffierent location than it will default to. For example my tar log shows me ... a... (3 Replies)
Discussion started by: littleIdiot
3 Replies

2. UNIX for Dummies Questions & Answers

tar command help -- extract single file

Hi, I want to view/display the contents of one file in tar file. For example if the tar file is sam.tar.gz and one of the file inside is E1.txt, how do i view the contents of this E1.txt file. Olso if I want to extract the E1.txt file only from sam.tar.gz how can i do that. Thanks in... (7 Replies)
Discussion started by: icefish
7 Replies

3. UNIX for Advanced & Expert Users

What is command to extract single file from an archieve?

I just want to extract one sigle file from an .ear archieve instead of extracting whole ear. Can anyone help me on this? (4 Replies)
Discussion started by: harshal_dcx
4 Replies

4. Shell Programming and Scripting

Extract single word from lines

Hi I have a huge line like the following: this word and many other words AA122134 other and other words and AA224466 and other other other other word AA667210 words I only want extract the words AA?????? and put them in a column, how could i do ? thx so much! (7 Replies)
Discussion started by: AdminLew
7 Replies

5. Shell Programming and Scripting

Awk: How to merge duplicate lines and print in a single

The input file: >cat module1 200611051053 95 200523457498 35 200617890187 57 200726098123 66 200645676712 71 200744556590 68 >cat module2 200645676712 ... (10 Replies)
Discussion started by: winter9
10 Replies

6. UNIX for Advanced & Expert Users

In a huge file, Delete duplicate lines leaving unique lines

Hi All, I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space. I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies

7. Shell Programming and Scripting

Removing duplicate records in a file based on single column

Hi, I want to remove duplicate records including the first line based on column1. For example inputfile(filer.txt): ------------- 1,3000,5000 1,4000,6000 2,4000,600 2,5000,700 3,60000,4000 4,7000,7777 5,999,8888 expected output: ---------------- 3,60000,4000 4,7000,7777... (5 Replies)
Discussion started by: G.K.K
5 Replies

8. Shell Programming and Scripting

Removing duplicate records in a file based on single column explanation

I was reading this thread. It looks like a simpler way to say this is to only keep uniq lines based on field or column 1. https://www.unix.com/shell-programming-scripting/165717-removing-duplicate-records-file-based-single-column.html Can someone explain this command please? How are there no... (5 Replies)
Discussion started by: cokedude
5 Replies

9. Shell Programming and Scripting

[Solved] Need to add Single quotes to particular lines

Hi Guys, I have the following file. DbName=DBNAME DbUser=USERID DbPass=PASSLL SrcLocation=/appl/data/VSTAR SrcFile1=gmb_dly_ind_sls_20120410133424.txt SrcFile2= IpLocation=/appl/data/VSTAR/global_daily/input/GMB IpFile=gmb_dly_ind_sls_20120410133424.txt... (4 Replies)
Discussion started by: mac4rfree
4 Replies

10. UNIX for Dummies Questions & Answers

[SOLVED] remove lines that have duplicate values in column two

Hi, I've got a file that I'd like to uniquely sort based on column 2 (values in column 2 begin with "comp"). I tried sort -t -nuk2,3 file.txtBut got: sort: multi-character tab `-nuk2,3' "man sort" did not help me out Any pointers? Input: Output: (5 Replies)
Discussion started by: pathunkathunk
5 Replies
DateTime::Locale::kw(3) 				User Contributed Perl Documentation				   DateTime::Locale::kw(3)

NAME
DateTime::Locale::kw SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'kw' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Cornish. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) De Lun De Merth De Merher De Yow De Gwener De Sadorn De Sul Abbreviated (format) Lun Mth Mhr Yow Gwe Sad Sul Narrow (format) 2 3 4 5 6 7 1 Wide (stand-alone) De Lun De Merth De Merher De Yow De Gwener De Sadorn De Sul Abbreviated (stand-alone) Lun Mth Mhr Yow Gwe Sad Sul Narrow (stand-alone) 2 3 4 5 6 7 1 Months Wide (format) Mys Genver Mys Whevrel Mys Merth Mys Ebrel Mys Me Mys Efan Mys Gortheren Mye Est Mys Gwyngala Mys Hedra Mys Du Mys Kevardhu Abbreviated (format) Gen Whe Mer Ebr Me Efn Gor Est Gwn Hed Du Kev Narrow (format) 1 2 3 4 5 6 7 8 9 10 11 12 Wide (stand-alone) Mys Genver Mys Whevrel Mys Merth Mys Ebrel Mys Me Mys Efan Mys Gortheren Mye Est Mys Gwyngala Mys Hedra Mys Du Mys Kevardhu Abbreviated (stand-alone) Gen Whe Mer Ebr Me Efn Gor Est Gwn Hed Du Kev Narrow (stand-alone) 1 2 3 4 5 6 7 8 9 10 11 12 Quarters Wide (format) Q1 Q2 Q3 Q4 Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) Q1 Q2 Q3 Q4 Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide BCE CE Abbreviated RC AD Narrow RC AD Date Formats Full 2008-02-05T18:30:30 = De Merth 5 Mys Whevrel 2008 1995-12-22T09:05:02 = De Gwener 22 Mys Kevardhu 1995 -0010-09-15T04:44:23 = De Sadorn 15 Mys Gwyngala -10 Long 2008-02-05T18:30:30 = 5 Mys Whevrel 2008 1995-12-22T09:05:02 = 22 Mys Kevardhu 1995 -0010-09-15T04:44:23 = 15 Mys Gwyngala -10 Medium 2008-02-05T18:30:30 = 5 Whe 2008 1995-12-22T09:05:02 = 22 Kev 1995 -0010-09-15T04:44:23 = 15 Gwn -10 Short 2008-02-05T18:30:30 = 05/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-010 Default 2008-02-05T18:30:30 = 5 Whe 2008 1995-12-22T09:05:02 = 22 Kev 1995 -0010-09-15T04:44:23 = 15 Gwn -10 Time Formats Full 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = De Merth 5 Mys Whevrel 2008 18:30:30 UTC 1995-12-22T09:05:02 = De Gwener 22 Mys Kevardhu 1995 09:05:02 UTC -0010-09-15T04:44:23 = De Sadorn 15 Mys Gwyngala -10 04:44:23 UTC Long 2008-02-05T18:30:30 = 5 Mys Whevrel 2008 18:30:30 UTC 1995-12-22T09:05:02 = 22 Mys Kevardhu 1995 09:05:02 UTC -0010-09-15T04:44:23 = 15 Mys Gwyngala -10 04:44:23 UTC Medium 2008-02-05T18:30:30 = 5 Whe 2008 18:30:30 1995-12-22T09:05:02 = 22 Kev 1995 09:05:02 -0010-09-15T04:44:23 = 15 Gwn -10 04:44:23 Short 2008-02-05T18:30:30 = 05/02/2008 18:30 1995-12-22T09:05:02 = 22/12/1995 09:05 -0010-09-15T04:44:23 = 15/09/-010 04:44 Default 2008-02-05T18:30:30 = 5 Whe 2008 18:30:30 1995-12-22T09:05:02 = 22 Kev 1995 09:05:02 -0010-09-15T04:44:23 = 15 Gwn -10 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 Mth 1995-12-22T09:05:02 = 22 Gwe -0010-09-15T04:44:23 = 15 Sad HHmm (HH:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 p.m. 1995-12-22T09:05:02 = 9:05 a.m. -0010-09-15T04:44:23 = 4:44 a.m. Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 p.m. 1995-12-22T09:05:02 = 9:05:02 a.m. -0010-09-15T04:44:23 = 4:44:23 a.m. M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 MEd (E, M-d) 2008-02-05T18:30:30 = Mth, 2-5 1995-12-22T09:05:02 = Gwe, 12-22 -0010-09-15T04:44:23 = Sad, 9-15 MMdd (dd/MM) 2008-02-05T18:30:30 = 05/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 MMM (LLL) 2008-02-05T18:30:30 = Whe 1995-12-22T09:05:02 = Kev -0010-09-15T04:44:23 = Gwn MMMd (MMM d) 2008-02-05T18:30:30 = Whe 5 1995-12-22T09:05:02 = Kev 22 -0010-09-15T04:44:23 = Gwn 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = Mth Whe 5 1995-12-22T09:05:02 = Gwe Kev 22 -0010-09-15T04:44:23 = Sad Gwn 15 MMMMd (d MMMM) 2008-02-05T18:30:30 = 5 Mys Whevrel 1995-12-22T09:05:02 = 22 Mys Kevardhu -0010-09-15T04:44:23 = 15 Mys Gwyngala MMMMEd (E MMMM d) 2008-02-05T18:30:30 = Mth Mys Whevrel 5 1995-12-22T09:05:02 = Gwe Mys Kevardhu 22 -0010-09-15T04:44:23 = Sad Mys Gwyngala 15 mmss (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = Mth, 2008-2-5 1995-12-22T09:05:02 = Gwe, 1995-12-22 -0010-09-15T04:44:23 = Sad, -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 Whe 1995-12-22T09:05:02 = 1995 Kev -0010-09-15T04:44:23 = -10 Gwn yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = Mth, 2008 Whe 5 1995-12-22T09:05:02 = Gwe, 1995 Kev 22 -0010-09-15T04:44:23 = Sad, -10 Gwn 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 Mys Whevrel 1995-12-22T09:05:02 = 1995 Mys Kevardhu -0010-09-15T04:44:23 = -10 Mys Gwyngala yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 Q1 1995-12-22T09:05:02 = 1995 Q4 -0010-09-15T04:44:23 = -10 Q3 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 yyyyMM (MM/yyyy) 2008-02-05T18:30:30 = 02/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 09/-010 yyyyMMMM (MMMM y) 2008-02-05T18:30:30 = Mys Whevrel 2008 1995-12-22T09:05:02 = Mys Kevardhu 1995 -0010-09-15T04:44:23 = Mys Gwyngala -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week De Lun SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.16.3 2014-06-10 DateTime::Locale::kw(3)
All times are GMT -4. The time now is 12:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy