Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Prepend 0 to a field in a record Post 303015556 by RudiC on Friday 6th of April 2018 01:48:07 PM
Old 04-06-2018
In order to retain the special structure of the fourth line's $12, try
Code:
awk -F\; '$12 == $12+0 {$12 = sprintf ("%03d", $12)} 1' OFS=";" file
11050;11001;;CREDITTRANC;5293218;NRATL;;;11095;;-1;014;3;29=0000;1.25
11050;11001;;DEBITTRANC;529328;NRATL;;;11095;;-1;014;3;29=0000;1.25
11050;11001;;DEBITTRANC;529328;NRATL;;;11095;;-1;001;3;29=0000;1.25
11050;11001;;CREDITTRANC;5293218;NRATL;;;11095;;-1;001/009;3;29=0000;1.25

These 2 Users Gave Thanks to RudiC For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

modify a few field of the record information

Hello, I have the following record in a text file, i would like modify some field: 1 - remove all space between ",", but the company name of word will not delete. Anyway, I can use the following statement to do it. 's/^ *//;s/ *, */,/g;s/ *$//' file 2. field #12, I need to modify to time... (11 Replies)
Discussion started by: happyv
11 Replies

2. Shell Programming and Scripting

how to replace field for each record

Hello, I have the following xml formatted file. I would like to get the newnumber field number and replace into customernumber for each record. For example: <XMLFORMAT> <customernumberR11>9</customernumberR11> ... (12 Replies)
Discussion started by: happyv
12 Replies

3. Shell Programming and Scripting

get a field from a record

I have a file as: A,B,C,D,E G,H,I,J,K I need to find if fourth field is blank or has a space and print that line to other file. I tried using awk but am not getting the desired result. Pls help. (6 Replies)
Discussion started by: praveenK_Dudala
6 Replies

4. Shell Programming and Scripting

Replace third field of the first record in a file....

Hi, I am new to unix and am trying to do something below: I have a pipe delimited file with millions of records. I need to replace the third column of the first record to the number of lines in the file. How can I do that. Will appreciate any advice and help. Thanks Simi (3 Replies)
Discussion started by: simi28
3 Replies

5. Shell Programming and Scripting

awk text record - prepend first field to all subsequent fields

Hello everyone, I've suddenly gotten very interested in sed and awk (and enjoying it quite a bit too) because of a large conversion project that we're working on. I'm currently stuck with a very inefficient process for processing text blocks. I'm sure someone here should be able to easily point out... (2 Replies)
Discussion started by: jameswatson3
2 Replies

6. Shell Programming and Scripting

Remove \n at the beginning of a field in a record.

Hi, In my file, I have few records which are split across multiple lines. File 1: ===== james,\n pre-auth completed,in patient,\n Fac_Id:23451,ramson,Dallas Expected is: ========== james,pre-auth completed,in patient,Fac_Id:23451,ramson,Dallas (8 Replies)
Discussion started by: machomaddy
8 Replies

7. Shell Programming and Scripting

Get last field specific record

i have file A as below contents --------------------------- Use descriptive thread titles when posting. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". For example, do not post questions For example, do not deliminated. output file as below:... (2 Replies)
Discussion started by: ANSHUMAN1983
2 Replies

8. Shell Programming and Scripting

Display combination of 4 field uniqe record and along with concatenate 5th and 6th field.

Table ACN|NAME|CITY|CTY|NO1|NO2 115|AKKK|ASH|IND|10|15 115|AKKK|ASH|IND|20|20 115|AKKK|ASH|IND|30|35 115|AKKK|ASH|IND|30|35 112|ABC|FL|USA|15|15 112|ABC|FL|USA|25|20 112|ABC|FL|USA|25|45 i have written shell script using cut command and awk programming getting error correct it and add... (5 Replies)
Discussion started by: udhal
5 Replies

9. Shell Programming and Scripting

How to replace value in each field until a certain character in each record?

Each record coming with column names. I have to replace them in each record as shown below TIME=20181219110000261|CHAN=FMBKHJBAAAADPCFNAAAAAABA|EVNT=SWIclst|VALU=Session FMBKHJBAAAADPCFNAAAAAABA started|SRC=NSS|UCPU=0|SCPU=0 Output should look like: ... (9 Replies)
Discussion started by: sudhakar1987
9 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 02:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy