Sponsored Content
Top Forums Shell Programming and Scripting Replace column by random number addition Post 302720227 by Yoda on Tuesday 23rd of October 2012 03:53:28 PM
Old 10-23-2012
Replace column by random number addition

Here is my problem:-

I have a file with pipe separated values.

Code:
CR|20121021|079|ABC|N|DLS|00038|DLS|04750|1330597704|634234|634|0
CR|20121021|079|ABC|N|DLS|00038|DLS|05118|2071690102|354|351|3
CR|20121021|079|ABC|N|DLS|00038|DLS|05140|960051505|1088|1088|0
CR|20121021|079|ABC|N|DLS|00038|DLS|05158|2071690102|804|801|3
CR|20121021|079|ABC|N|DLS|00038|DLS|05858|589505306|473|473|0
CR|20121021|079|ABC|N|DLS|00038|DLS|26456|-1482184796|371|371|0
CR|20121021|079|ABC|N|DLS|00038|DLS|30036|1549556811|2001|1982|19
CR|20121021|079|ABC|N|DLS|00038|DLS|30038|1330597704|2460|24600|0
CR|20121021|079|ABC|N|DLS|00038|DLS|30130|218959107|1908|1894|14
CR|20121021|079|ABC|N|DLS|00038|DLS|30266|2071690102|468|468|0

Now I want to replace field: 10 (highlighted) by adding a random number to field number: 11. But the random number has to be generated based on decimal places of field: 11

E.g: In the first record, the 11th field value is 634234, so we have to generate a 4 digit random number and add to field number 11.

Hence if 11th field is

6 digits - random number should be 4 digits
5 digits - random number should be 3 digits
4 digits - random number should be 2 digits
3 digits - random number should be 1 digits

Please assist.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sed to replace second number in a random string

I need a sed line that will take STDM111 and change it to STDM161 the STDM will always be constant but the 3 numbers after will be random, I just need it to always replace the middle number with 6 regardless of what the numbers are. (8 Replies)
Discussion started by: glev2005
8 Replies

2. Shell Programming and Scripting

Previous Column Value (addition)

Good day, First off, I would just like to say that I've been helped by a lot of the posts here in my own scripting work in the past few months. I've been a long time roamer, but first time poster. That being said, I'm stuck trying to figure out this issue (For computational research, not a... (4 Replies)
Discussion started by: Eblue562
4 Replies

3. UNIX for Dummies Questions & Answers

replace all numbers in column with another number in bash

Hi, I've been trying to replace the numbers in the first column of my text file with all ones, unless the number is equal to 8. I have this: 1 1 11 123 258 2 1 9 135 175 1 1 15 143 274 8 1 13 153 172 8 1 13 154 166 8 1 13 154 167 3 1 15 237 255 4 1 15 243 202 1 1 13 133 166... (4 Replies)
Discussion started by: goodbenito
4 Replies

4. Shell Programming and Scripting

Using SED to replace a random number?

Hi all, I need to run a number of scripts which have a certain phrase on them so I have identified these by; grep -l 100 *script | sort -u Normally I could just run something along the lines of; for i in `grep -l 100 *script | sort -u`; do ./${i}; done However before I run each of... (0 Replies)
Discussion started by: JayC89
0 Replies

5. UNIX for Dummies Questions & Answers

Multiple number addition

Friends , Can u tel me how can i have done multiple addition using shell script ? Expected Output can be : 1 4 6 --------- Total - 11 (4 Replies)
Discussion started by: meetsubhas
4 Replies

6. Shell Programming and Scripting

Replace 2nd column for each line in a csv file with fixed string+random number

Hi experts, My csv file looks like this U;cake;michael;temp;;;; U;bread;john;temp;;;; U;cocktails;sarah;temp;;;; I'd like to change the value fo 2nd column to cf+random number , which will look maybe something like this U;cf20187;michael;temp;;;; U;cf8926;john;temp;;;;... (7 Replies)
Discussion started by: tententen
7 Replies

7. UNIX for Dummies Questions & Answers

how to generate random number as as the first column of a txt file

Dear all, I have a question. I have a txt file say 4000 rows X 1800 Column. I 'd like to creat a new column as the first column which is a column of random numbers (n=4000) thanks a lot! Lin (2 Replies)
Discussion started by: forevertl
2 Replies

8. Shell Programming and Scripting

Find number of characters in a column and replace

Hi all, I want to count total no. of characters in a column. and if no. of charaters are more than 3 then it must replace it by splitted string. ie, it must place a space after 3 characters. Ex: 21 435g asd3dd jklfjwe wer column number 3 has 4 alphanumeric character, so it must be splitted... (3 Replies)
Discussion started by: CAch
3 Replies

9. Shell Programming and Scripting

Group/concatenate certain column and basis on this do addition on other column

Hi Experts, Need your support I want to group/concatenate column 1,2,12 and 13 and if found duplicate then need to sum value of column 17,20,21 and column22. After concatenation if found unique then no action to be taken. Secondly want to make duplicate rows basis on grouping/concatenation of... (1 Reply)
Discussion started by: as7951
1 Replies

10. Shell Programming and Scripting

Replace all string matches in file with unique random number

Hello Take this file... Test01 Ref test Version 01 Test02 Ref test Version 02 Test66 Ref test Version 66 Test99 Ref test Version 99 I want to substitute every occurrence of Test{2} with a unique random number, so for example, if I was using sed, substitution would be something... (1 Reply)
Discussion started by: funkman
1 Replies
dlpi(7) 						 Miscellaneous Information Manual						   dlpi(7)

NAME
dlpi - data link provider interface DESCRIPTION
This manual page gives a brief description on DLPI (the data link provider interface) and how to interface with the set of API's that are provided by DLPI. HP-UX DLPI serves as a Layer 2 (Data Link Layer) of an OSI architecture. DLPI serves as an interface between LAN device drivers and DLPI users. DLPI is intended for use by experienced network users only. HP-UX DLPI has two broader sets of interface. The first set of interfaces are provided as per the DLPI 2.0 standard and the second set that are HP extensions to the standard. HP-UX DLPI also provides interfaces to device drivers to interface with STREAMS modules and DLPI applications. For STREAMS Modules and DLPI Applications Hewlett-Packard's implementation of DLPI is a Style 2 service provider. The Style 2 provider requires a DLS user to identify a PPA explic- itly, using a special attach service primitive. Refer to the lan(7) manual page for more information on PPA. HP DLPI offers the following services to STREAMS modules and DLPI applications: o Clone (maximum of 3992) and non-clone (maximum of 100) access. o Support for Ethernet/IEEE802.3, FDDI and Token Ring interfaces. o Support for connectionless and connection-mode services (connection-mode services are supported only over IEEE802.3 and Token Ring). o Supports raw-mode services. o ioctl is supported for doing device-specific control and diagnostic requests. o Support for third-party device drivers. o Support for all levels of promiscuous mode. HP DLPI does not offer the following for STREAMS modules and DLPI applications: o Quality of Service (QOS) management. o Connection Management STREAMS: and over connection-oriented STREAMS. o Acknowledged connectionless-mode services. The DLPI requests based on DLPI 2.0 standard are defined in see dlpi(4). HP extensions for DLPI are defined in see dlpi_ext(4). Device File Format To access LAN drivers via DLPI interface, DLS users must use the following device files: Name Type Major # Minor # Access Type ---- ---- ------- ------- ----------- /dev/dlpi c 72 0x77 Clone access /dev/dlpiX c 119 0xX Non-Clone access For Device Drivers HP-UX DLPI is of non-native design. The drivers and DLPI are not coupled together and exists as individual components on the system. The non-native DLPI supports two kinds of drivers. Tightly coupled and loosely coupled drivers. DLPI provides interfaces to tightly coupled and loosely coupled drivers. DLPI serves as a sole interface to DLS users for tightly coupled drivers. Whereas, a loosely coupled driver depends on DLPI only to provide information to user-space commands lanscan(1M) and nwmgr(1M) for display purposes. The interfaces for device drivers is defined in see dlpi_drv(4). DLPI provides the following functionality for tightly coupled drivers: o Infrastructure that allows drivers to communicate with upper layer STREAMS modules or applications. o Infrastructure for protocol, multicast and promiscuous processing. o Infrastructure for asynchronous processing of control. o Inbound frame processing. o Processing link up and down events. o Repository for all registered interfaces and associated information. o Outbound processing before hand off to physical drivers. DLPI provides its services through three header files that are exported. The header files and are for user space applications and kernel level STREAMS modules. The header file is for physical and logical drivers. WARNINGS
Various implementations of DLPI exists within HP-UX for special technologies like ATM, Hyper Fabric, etc.; but the DLPI that supports LAN class drivers (tightly coupled) is the one covered by this manual page. The and commands are deprecated. These commands will be removed in a future HP-UX release. HP recommends the use of replacement command nwmgr(1M) to perform all network interface-related tasks. AUTHOR
was developed by HP, based on DLPI 2.0 standard. SEE ALSO
lanscan(1M), nwmgr(1M), dlpi(4), dlpi_drv(4), dlpi_ext(4), lan(7). dlpi(7)
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy