Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Compare two files, if the columns are same then replace next column with some value Post 303045716 by RudiC on Friday 10th of April 2020 09:47:57 AM
Old 04-10-2020
Try
Code:
awk -F, 'NR==FNR {T[$1]=$2; next} $3 ~ /^sign/ {$3=T[$1]} 1' OFS=, file2 file1
empname,place,empdep
aaaa ,city1,001
bbbb,city2,002
dddd,city1,005
ffff,city5,007
hhhh,city7,009

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find common lines using just one column to compare and result with all columns

Hi. If we have this file A B C 7 8 9 1 2 10 and this other file A C D F 7 9 2 3 9 2 3 4 The result i´m looking for is intersection with A B C D F so the answer here will be (10 Replies)
Discussion started by: alcalina
10 Replies

2. Ubuntu

How to compare two columns and fetch the common data with additional column

Dear All, I am new to this forum and please ignore my little knowledge :p I have two types of data (a subset is given below) data version 1: 439798 2 1 451209 1 2 508696 2 1 555760 2 1 582757 1 2 582889 1 2 691827... (2 Replies)
Discussion started by: evoll
2 Replies

3. Shell Programming and Scripting

Compare Two Files(Column By Column) In Perl or shell

Hi, I am writing a comparator script, which comapre two txt files(column by column) below are the precondition of this comparator 1)columns of file are not seperated Ex. file1.txt 8888812341181892 1243548895685687 8945896789897789 1111111111111111 file2.txt 9578956789567897... (2 Replies)
Discussion started by: kumar96877
2 Replies

4. Shell Programming and Scripting

awk compare column n replace with in one file

hi Friends need to compare columns in one file where the data looks like below laptop,IBM phone,samsung car,rental user1,laptop user2,laptop user3,phone want to get output as laptop,IBM phone,samsung car,rental user1,IBM user2,IBM user3,samsung need to seach $2 in array of $1 and... (4 Replies)
Discussion started by: arun1401
4 Replies

5. Shell Programming and Scripting

Combine columns from many files but keep them aligned in columns-shorter left column issue

Hello everyone, I searched the forum looking for answers to this but I could not pinpoint exactly what I need as I keep having trouble. I have many files each having two columns and hundreds of rows. first column is a string (can have many words) and the second column is a number.The files are... (5 Replies)
Discussion started by: isildur1234
5 Replies

6. Shell Programming and Scripting

Compare first column of 2 files and replace

Hi All, I have 2 files in the following format : File 1 S00999999|BHANU|TEST|007 JOHN DOE APT 999||VENGA HIGHWAY|MA|09566|SCO DUAL|20140201|20140331|20140401|20140630|20140327| S00888888|BU|TES|009 JOHN DOE APT 909||SENGA HIGHWAY|MA|08566|SCO... (1 Reply)
Discussion started by: nua7
1 Replies

7. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies

8. Shell Programming and Scripting

Compare two columns and replacing it with value from third column!!

Hi, I am new to Unix and I am finding it hard to fix a particular logic. The context is as below. File 1 : This contains of 5 fields : Type | Bank Code | Account | Name | Date/Time 60|ABC123|TX123456|XXXX|YYYYMMDDHH:MM:SS 72|ABC123|MYD34561|XXXX|YYYYMMDDHH:MM:SS... (4 Replies)
Discussion started by: DJose
4 Replies

9. Shell Programming and Scripting

Compare and replace two columns from two files

Hello, I have two text tab delimited files File 1 has 30 columns. I am pasting only first 9 Chr Position Ref Alt Score Gene HGVS_C HGVS_P Coding_Consequence dbSNP 1 17312743 C T 1 Gene1 - ... (2 Replies)
Discussion started by: nans
2 Replies

10. Shell Programming and Scripting

Need awk or Shell script to compare Column-1 of two different CSV files and print if column-1 matche

Example: I have files in below format file 1: zxc,133,joe@example.com cst,222,xyz@example1.com File 2 Contains: hxd hcd jws zxc cst File 1 has 50000 lines and file 2 has around 30000 lines : Expected Output has to be : hxd hcd jws (5 Replies)
Discussion started by: TestPractice
5 Replies
CheckDigits(3pm)					User Contributed Perl Documentation					  CheckDigits(3pm)

NAME
Algorithm::CheckDigits - Perl extension to generate and test check digits SYNOPSIS
perl -MAlgorithm::CheckDigits -e Algorithm::CheckDigits::print_methods or use Algorithm::CheckDigits; @ml = Algorithm::CheckDigits->method_list(); $isbn = CheckDigits('ISBN'); if ($isbn->is_valid('3-930673-48-7')) { # do something } $cn = $isbn->complete('3-930673-48'); # $cn = '3-930673-48-7' $cd = $isbn->checkdigit('3-930673-48-7'); # $cd = '7' $bn = $isbn->basenumber('3-930673-48-7'); # $bn = '3-930673-48' ABSTRACT
This module provides a number of methods to test and generate check digits. For more information have a look at the web site www.pruefziffernberechnung.de (german). SUBROUTINES
/METHODS CheckDigits($method) Returns an object of an appropriate Algorithm::CheckDigits class for the given algorithm. Dies with an error message if called with an unknown algorithm. See below for the available algorithms. Every object understands the following methods: is_valid($number) Returns true or false if $number contains/contains no valid check digit. complete($number) Returns a string representation of $number completed with the appropriate check digit. checkdigit($number) Extracts the check digit from $number if $number contains a valid check digit. basenumber($number) Extracts the basenumber from $number if $number contains a valid check digit. Algorithm::CheckDigits::method_list() Returns a list of known methods for check digit computation. Algorithm::CheckDigits::print_methods() Returns a list of known methods for check digit computation. You may use the following to find out which methods your version of Algorithm::CheckDigits provides and where to look for further information. perl -MAlgorithm::CheckDigits -e Algorithm::CheckDigits::print_methods CHECK SUM METHODS At the moment these methods to compute check digits are provided: (vatrn - VAT Return Number, in german ustid UmsatzSTeuer-ID) m07-001 See Algorithm::CheckDigits::M07_001. euronote, m09-001 European bank notes, see Algorithm::CheckDigits::M09_001. amex, bahncard, diners, discover, enroute, eurocard, happydigits, isin, jcb, klubkarstadt, mastercard, miles&more, visa, m09-001, imei, imeisv See Algorithm::CheckDigits::M10_001. siren, siret, m10-002 See Algorithm::CheckDigits::M10_002. ismn, m10-003 See Algorithm::CheckDigits::M10_003. ean, iln, isbn13, nve, 2aus5, m10-004 See Algorithm::CheckDigits::M10_004. identcode_dp, leitcode_dp, m10-005 See Algorithm::CheckDigits::M10_005. rentenversicherung, m10-006 See Algorithm::CheckDigits::M10_006. sedol, m10-008 See Algorithm::CheckDigits::M10_008. betriebsnummer, m10-009 See Algorithm::CheckDigits::M10_009. postscheckkonti, m10-010 See Algorithm::CheckDigits::M10_010. ups, m10-011 See Algorithm::CheckDigits::M10_011. hkid, isbn, issn, nhs_gb, ustid_pt, vat_sl, wagonnr_br, m11-001 See Algorithm::CheckDigits::M11_001. pzn, m11-002 See Algorithm::CheckDigits::M11_002. pkz, m11-003 See Algorithm::CheckDigits::M11_003. cpf, titulo_eleitor, m11-004 See Algorithm::CheckDigits::M11_004. ccc_es, m11-006 See Algorithm::CheckDigits::M11_006. ustid_fi, vatrn_fi, m11-007 See Algorithm::CheckDigits::M11_007. ustid_dk, vatrn_dk, m11-008 See Algorithm::CheckDigits::M11_008. nric_sg, m11-009 See Algorithm::CheckDigits::M11_009. ahv_ch, m11-010 See Algorithm::CheckDigits::M11_010. ustid_nl, vatrn_nl, m11-011 See Algorithm::CheckDigits::M11_011. bwpk_de, m11-012 See Algorithm::CheckDigits::M11_012. ustid_gr, vatrn_gr, m11-013 See Algorithm::CheckDigits::M11_013. esr5_ch, m11-015 See Algorithm::CheckDigits::M11_015. ustid_pl, vatrn_pl, m11-016 See Algorithm::CheckDigits::M11_016. ecno, ec-no, einecs, elincs, m11-017 See Algorithm::CheckDigits::M11_017. isan, m16-001 See Algorithm::CheckDigits::M16_001. dni_es, m23-001 See Algorithm::CheckDigits::M23_001. ustid_ie, vatrn_ie, m23-002 See Algorithm::CheckDigits::M23_002. code_39, m43-001 See Algorithm::CheckDigits::M43_001. ustid_lu, vatrn_lu, m89-001 See Algorithm::CheckDigits::M89_001. ustid_be, vatrn_be, m97-001 See Algorithm::CheckDigits::M97_001. iban, m97-002 See Algorithm::CheckDigits::M97_002. upc, mbase-001 See Algorithm::CheckDigits::MBase_001. blutbeutel, bzue_de, ustid_de, vatrn_de, mbase-002 See Algorithm::CheckDigits::MBase_002. sici, mbase-003 See Algorithm::CheckDigits::MBase_003. pa_de, mxx-001 See Algorithm::CheckDigits::MXX_001. cas, mxx-002 See Algorithm::CheckDigits::MXX_002. dem, mxx-003 Old german bank notes (DEM), see Algorithm::CheckDigits::MXX_003. ustid_at, vatrn_at, mxx-004 See Algorithm::CheckDigits::MXX_004. esr9_ch, mxx-005 See Algorithm::CheckDigits::MXX_005. verhoeff, mxx-006 Verhoeff scheme, see Algorithm::CheckDigits::MXX_006 or Algorithm::Verhoeff EXPORT None by default. SEE ALSO
perl, www.pruefziffernberechnung.de. AUTHOR
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de> THANKS
Petri Oksanen made me aware that CheckDigits('IMEI') would invoke no test at all since there was no entry for this in the methods hash. COPYRIGHT AND LICENSE
Copyright 2004-2006 by Mathias Weidner This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2008-06-06 CheckDigits(3pm)
All times are GMT -4. The time now is 11:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy