Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Des/awk for change format and adding integers in a column of data? Post 302856203 by Twinklefingers on Monday 23rd of September 2013 10:59:52 AM
Old 09-23-2013
Des/awk for change format and adding integers in a column of data?

Greetings!

I need a quick way to change the format in a table of data

Here is an example of the input:
Code:
10	72	Value=177	VDB=0.0245	Value4=0,0,171,0
10	274	Value=238	VDB=0.0433	Value4=29,0,205,0
10	312	Value=222	VDB=0.0384	Value4=8,0,190,19
10	540	Value=405	VDB=0.0391	Value4=13,30,153,195
10	542	Value=403	VDB=0.0384	Value4=45,35,121,188
10	637	Value=341	VDB=0.0418	Value4=0,1,122,195
10	645	Value=370	VDB=0.0368	Value4=0,1,131,211
10	674	Value=366	VDB=0.0323	Value4=0,5,148,200
10	854	Value=356	VDB=0.0418	Value4=14,11,188,119
10	888	Value=396	VDB=0.0374	Value4=0,0,209,176
10	892	Value=397	VDB=0.0351	Value4=0,1,210,176
10	909	Value=402	VDB=0.0374	Value4=1,6,205,186

What I need is the "Value4" column to be just a number (no text) and that number is the total of all the comma-separated integers.

Desired output:
Code:
10	72	Value=177	VDB=0.0245	171
10	274	Value=238	VDB=0.0433	234
10	312	Value=222	VDB=0.0384	217
10	540	Value=405	VDB=0.0391	391
10	542	Value=403	VDB=0.0384	389
10	637	Value=341	VDB=0.0418	318
10	645	Value=370	VDB=0.0368	343
10	674	Value=366	VDB=0.0323	353
10	854	Value=356	VDB=0.0418	332
10	888	Value=396	VDB=0.0374	385
10	892	Value=397	VDB=0.0351	387
10	909	Value=402	VDB=0.0374	398

I feel like this shouldn't be too difficult to do using sed/awk, but can't figure it out.

Any help is greatly appreciated.

Thanks!
 

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Format - Inventory Row data into Column - Awk - Nawk

Hi All, I have the following file that has computer data for various pcs in my network... Snap of the file is as follows ******************************************************************************* Serial 123456 Computer IP Address lo0:... (1 Reply)
Discussion started by: aavam
1 Replies

2. Shell Programming and Scripting

awk - script help: column to row format of data allignment?

Experts Good day, I have the following data, file1 BRAAGRP1 A2X B2X C2X D2X BRBGRP12 A3X B3X Z10 D09 BRC1GRP2 LO01 (4 Replies)
Discussion started by: rveri
4 Replies

3. Shell Programming and Scripting

Change data in one column with data from another file's column

Hello, I have this file outputData: # cat /tmp/outputData __Capacity^6^NBSC01_Licences^L3_functionality_for_ESB_switch __Capacity^2100^NBSC01_Licences^Gb_over_IP __Capacity^1837^NBSC01_Licences^EDGE_BSS_Fnc __Capacity^1816^NBSC01_Licences^GPRS_CS3_and_CS4... (1 Reply)
Discussion started by: nypreH
1 Replies

4. Shell Programming and Scripting

Adding new column data in csv from UNIX

Adding new column data in csv from UNIX Hi I need to add new column data daily to existing csv file. Please assist 7/11 7/10 7/9 7/8 space 10 GB 20 GB I was able to generate current day's data in csv but unable to add the previous 30 days data to the same csv Please use code tags,... (2 Replies)
Discussion started by: archana25
2 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 07:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy