Sponsored Content
Top Forums Shell Programming and Scripting Append the data to first column Post 302321762 by ravi_rn on Tuesday 2nd of June 2009 05:16:19 AM
Old 06-02-2009
Append the data to first column

Hi,

The below is the content of the file.

008.03.50.21|ID4|0015a3f01cf3
008.04.20.16|ID3|0015a3f02337
008.04.20.17|ID4_1xVoice|00131180d80e
008.04.20.03|ID3_1xVoice|0015a3694125
008.04.30.05|ID3_1xVoice|0015a3f038af
008.06.30.17|ID3_1xVoice|00159660d454
009.05.70.04|ID3_1xVoice|0015a3ea814b
009.05.70.12|ID3_1xVoice|0015a36922f9
013.01.50.09|Service|0015a2d82070

I need to append "_1" to the first column only. The output should look like

008.03.50.21_1|ID4|0015a3f01cf3
008.04.20.16_1|ID3|0015a3f02337
008.04.20.17_1|ID4_1xVoice|00131180d80e
008.04.20.03_1|ID3_1xVoice|0015a3694125
008.04.30.05_1|ID3_1xVoice|0015a3f038af
008.06.30.17_1|ID3_1xVoice|00159660d454
009.05.70.04_1|ID3_1xVoice|0015a3ea814b
009.05.70.12_1|ID3_1xVoice|0015a36922f9
013.01.50.09_1|Service|0015a2d82070

please help me in writing regular expression in unix.

Thanks in advance for helping in solving the above issue.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

2. Shell Programming and Scripting

Advanced: Sort, count data in column, append file name

Hi. I am not sure the title gives an optimal description of what I want to do. Also, I tried to post this in the "UNIX for Dummies Questions & Answers", but it seems no-one was able to help out. I have several text files that contain data in many columns. All the files are organized the same... (14 Replies)
Discussion started by: JamesT
14 Replies

3. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

4. Shell Programming and Scripting

Append data to first column delimited file

Hi, I have a data like Input: 12||34|56|78 Output: XYZ|12||34|56|78 I tried like this , but it puts it on another line awk -F "|" ' BEGIN {"XYZ"} {print $0} 'file Any quick suggessitons in sed/awk ? am using HP-UX (3 Replies)
Discussion started by: selvankj
3 Replies

5. Shell Programming and Scripting

To append new data at the end of each line based on substring of last column

Hi guys, I need to append new data at the end of each line of the files. This new data is based on substring (3rd fields) of last column. Input file xxx.csv: U1234|1-5X|orange|1-5X|Act|1-5X|0.1 /sac/orange 12345 0 U5678|1-7X|grape|1-7X|Act|1-7X|0.1 /sac/grape 5678 0... (5 Replies)
Discussion started by: null7
5 Replies

6. Shell Programming and Scripting

Matching column then append to existing File as new column

Good evening I have the below requirements, as I am not an experts in Linux/Unix and am looking for your ideas how I can do this. I have file called file1 and file2. I need to get the second column which is text1_random_alphabets and find that in file 2, if it's exists then print the 3rd... (4 Replies)
Discussion started by: mychbears
4 Replies

7. Shell Programming and Scripting

Append data with substring of nth column fields using awk

Hi guys, I have problem to append new data at the end of each line of the files where it takes whole value of the nth column. My expected result i just want to take a specific value only. This new data is based on substring of 11th, 12th 13th column that has comma seperated value. My code: awk... (4 Replies)
Discussion started by: null7
4 Replies

8. Shell Programming and Scripting

Matching column value from 2 different file using awk and append value from different column

Hi, I have 2 csv files. a.csv HUAWEI,20LMG011_DEKET_1296_RTN-980_IDU-1-11-ISV3-1(to LAMONGAN_M),East_Java,20LMG011_DEKET_1296_RTN-980_IDU-1,20LMG011,20LMG 027_1287_LAMONGAN_RTN980_IDU1,20LMG027,1+1(HSB),195.675,20LMG011-20LMG027,99.9995,202.6952012... (7 Replies)
Discussion started by: tententen
7 Replies

9. Shell Programming and Scripting

awk to Sum columns when other column has duplicates and append one column value to another with Care

Hi Experts, Please bear with me, i need help I am learning AWk and stuck up in one issue. First point : I want to sum up column value for column 7, 9, 11,13 and column15 if rows in column 5 are duplicates.No action to be taken for rows where value in column 5 is unique. Second point : For... (1 Reply)
Discussion started by: as7951
1 Replies

10. Shell Programming and Scripting

awk script to append suffix to column when column has duplicated values

Please help me to get required output for both scenario 1 and scenario 2 and need separate code for both scenario 1 and scenario 2 Scenario 1 i need to do below changes only when column1 is CR and column3 has duplicates rows/values. This inputfile can contain 100 of this duplicated rows of... (1 Reply)
Discussion started by: as7951
1 Replies
cpustat(1M)															       cpustat(1M)

NAME
cpustat - monitor system behavior using CPU performance counters SYNOPSIS
cpustat -c eventspec [-c eventspec]... [-p period] [-sntD] [ interval [count]] cpustat -h The cpustat utility allows CPU performance counters to be used to monitor the overall behavior of the CPUs in the system. If interval is specified, cpustat samples activity every interval seconds, repeating forever. If a count is specified, the statistics are repeated count times. If neither are specified, an interval of five seconds is used, and there is no limit to the number of samples that are taken. The following options are supported: -c eventspec Specifies a set of events for the CPU performance counters to monitor. The syntax of these event specifications is: [picn=]eventn[,attr[n][=val]][,[picn=]eventn [,attr[n][=val]],...,] You can use the -h option to obtain a list of available events and attributes. This causes generation of the usage message. You can omit an explicit counter assignment, in which case cpustat attempts to choose a capable counter automatically. Attribute values can be expressed in hexadecimal, octal, or decimal notation, in a format suitable for strtoll(3C). An attribute present in the event specification without an explicit value receives a default value of 1. An attribute without a corresponding counter number is applied to all counters in the specification. The semantics of these event specifications can be determined by reading the CPU manufacturer's documentation for the events. Multiple -c options can be specified, in which case the command cycles between the different event settings on each sample. -D Enables debug mode. -h Prints an extensive help message on how to use the utility and how to program the processor-dependent counters. -p period Causes cpustat to cycle through the list of eventspecs every period seconds. The tool sleeps after each cycle until period seconds have elapsed since the first eventspec was measured. When this option is present, the optional count parameter specifies the number of total cycles to make (instead of the num- ber of total samples to take). If period is less than the number of eventspecs times interval, the tool acts as it period is 0. -s Creates an idle soaker thread to spin while system-only eventspecs are bound. One idle soaker thread is bound to each CPU in the current processor set. System-only eventspecs contain both the nouser and the sys tokens and measure events that occur while the CPU is operating in privileged mode. This option prevents the kernel's idle loop from running and trigger- ing system-mode events. -n Omits all header output (useful if cpustat is the beginning of a pipeline). -t Prints an additional column of processor cycle counts, if available on the current architecture. A closely related utility, cputrack(1), can be used to monitor the behavior of individual applications with little or no interference from other activities on the system. The cpustat utility must be run by the super-user, as there is an intrinsic conflict between the use of the CPU performance counters sys- tem-wide by cpustat and the use of the CPU performance counters to monitor an individual process (for example, by cputrack.) Once any instance of this utility has started, no further per-process or per-LWP use of the counters is allowed until the last instance of the utility terminates. The times printed by the command correspond to the wallclock time when the hardware counters were actually sampled, instead of when the program told the kernel to sample them. The time is derived from the same timebase as gethrtime(3C). The processor cycle counts enabled by the -t option always apply to both user and system modes, regardless of the settings applied to the performance counter registers. On some hardware platforms running in system mode using the "sys" token, the counters are implemented using 32-bit registers. While the kernel attempts to catch all overflows to synthesize 64-bit counters, because of hardware implementation restrictions, overflows can be lost unless the sampling interval is kept short enough. The events most prone to wrap are those that count processor clock cycles. If such an event is of interest, sampling should occur frequently so that less than 4 billion clock cycles can occur between samples. The output of cpustat is designed to be readily parseable by nawk(1) and perl(1), thereby allowing performance tools to be composed by embedding cpustat in scripts. Alternatively, tools can be constructed directly using the same APIs that cpustat is built upon using the facilities of libcpc(3LIB). See cpc(3CPC). The cpustat utility only monitors the CPUs that are accessible to it in the current processor set. Thus, several instances of the utility can be running on the CPUs in different processor sets. See psrset(1M) for more information about processor sets. Because cpustat uses LWPs bound to CPUs, the utility might have to be terminated before the configuration of the relevant processor can be changed. EXAMPLES
SPARC Example 1: Measuring External Cache References and Misses The following example measures misses and references in the external cache. These occur while the processor is operating in user mode on an UltraSPARC machine. example% cpustat -c EC_ref,EC_misses 1 3 time cpu event pic0 pic1 1.008 0 tick 69284 1647 1.008 1 tick 43284 1175 2.008 0 tick 179576 1834 2.008 1 tick 202022 12046 3.008 0 tick 93262 384 3.008 1 tick 63649 1118 3.008 2 total 651077 18204 Example 2: Measuring Branch Prediction Success on Pentium 4 The following example measures branch mispredictions and total branch instructions in user and system mode on a Pentium 4 machine. example% cpustat -c pic12=branch_retired,emask12=0x4,pic14=branch_retired, emask14=0xf,sys 1 3 time cpu event pic12 pic14 1.010 1 tick 458 684 1.010 0 tick 305 511 2.010 0 tick 181 269 2.010 1 tick 469 684 3.010 0 tick 182 269 3.010 1 tick 468 684 3.010 2 total 2063 3101 Example 3: Counting Memory Accesses on Opteron The following example determines the number of memory accesses made through each memory controller on an Opteron, broken down by internal memory latency: cpustat -c pic0=NB_mem_ctrlr_page_access,umask0=0x01, pic1=NB_mem_ctrlr_page_access,umask1=0x02, pic2=NB_mem_ctrlr_page_access,umask2=0x04,sys 1 time cpu event pic0 pic1 pic2 1.003 0 tick 41976 53519 7720 1.003 1 tick 5589 19402 731 2.003 1 tick 6011 17005 658 2.003 0 tick 43944 45473 7338 3.003 1 tick 7105 20177 762 3.003 0 tick 47045 48025 7119 4.003 0 tick 43224 46296 6694 4.003 1 tick 5366 19114 652 By running the cpustat command, the super-user forcibly invalidates all existing performance counter context. This can in turn cause all invocations of the cputrack command, and other users of performance counter context, to exit prematurely with unspecified errors. If cpustat is invoked on a system that has CPU performance counters which are not supported by Solaris, the following message appears: cpustat: cannot access performance counters - Operation not applicable This error message implies that cpc_open() has failed and is documented in cpc_open(3CPC). Review this documentation for more information about the problem and possible solutions. If a short interval is requested, cpustat might not be able to keep up with the desired sample rate. In this case, some samples might be dropped. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcpcu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ cputrack(1), nawk(1), perl(1), iostat(1M), prstat(1M), psrset(1M), vmstat(1M), cpc(3CPC), cpc_open(3CPC), cpc_bind_cpu(3CPC), geth- rtime(3C), strtoll(3C), libcpc(3LIB), attributes(5) When cpustat is run on a Pentium 4 with HyperThreading enabled, a CPC set is bound to only one logical CPU of each physical CPU. See cpc_bind_cpu(3CPC). 18 Jul 2005 cpustat(1M)
All times are GMT -4. The time now is 11:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy