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
DAHDI_HARDWARE(8)					User Contributed Perl Documentation					 DAHDI_HARDWARE(8)

NAME
dahdi_hardware - Shows Dahdi hardware devices. SYNOPSIS
dahdi_hardware [-v][-x] OPTIONS
-v Verbose ouput - show spans used by each device etc. Currently only implemented for the Xorcom Astribank. -x Show disconnected Astribank unit, if any. DESCRIPTION
Show all dahdi hardware devices. Devices are recognized according to lists of PCI and USB IDs in Dahdi::Hardware::PCI.pm and Dahdi::Hardware::USB.pm . For PCI it is possible to detect by sub-vendor and sub-product ID as well. The first output column is the connector: a bus specific field that shows where this device is. The second field shows which driver should handle the device. a "-" sign marks that the device is not yet handled by this driver. A "+" sign means that the device is handled by the driver. For the Xorcom Astribank (and in the future: for other Dahdi devices) some further information is provided from the driver. Those extra lines always begin with spaces. Example output: Without drivers loaded: usb:001/002 xpp_usb- e4e4:1152 Astribank-multi FPGA-firmware usb:001/003 xpp_usb- e4e4:1152 Astribank-multi FPGA-firmware pci:0000:01:0b.0 wctdm- e159:0001 Wildcard TDM400P REV H With drivers loaded, without -v: usb:001/002 xpp_usb+ e4e4:1152 Astribank-multi FPGA-firmware usb:001/003 xpp_usb+ e4e4:1152 Astribank-multi FPGA-firmware pci:0000:01:0b.0 wctdm+ e159:0001 Wildcard TDM400P REV E/F With drivers loaded, with -v: usb:001/002 xpp_usb+ e4e4:1152 Astribank-multi FPGA-firmware LABEL=[usb:123] CONNECTOR=usb-0000:00:1d.7-1 XBUS-00/XPD-00: FXS Span 2 XBUS-00/XPD-10: FXS Span 3 XBUS-00/XPD-20: FXS Span 4 XBUS-00/XPD-30: FXS Span 5 usb:001/003 xpp_usb+ e4e4:1152 Astribank-multi FPGA-firmware LABEL=[usb:4567] CONNECTOR=usb-0000:00:1d.7-4 XBUS-01/XPD-00: FXS Span 6 XPP-SYNC XBUS-01/XPD-10: FXO Span 7 XBUS-01/XPD-20: FXO Span 8 XBUS-01/XPD-30: FXO Span 9 pci:0000:01:0b.0 wctdm+ e159:0001 Wildcard TDM400P REV E/F perl v5.14.2 2009-04-20 DAHDI_HARDWARE(8)
All times are GMT -4. The time now is 05:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy