Sponsored Content
Top Forums Shell Programming and Scripting Display combination of 4 field uniqe record and along with concatenate 5th and 6th field. Post 302959356 by Don Cragun on Sunday 1st of November 2015 01:36:13 PM
Old 11-01-2015
Or you could make some trivial changes to the awk script I suggested before:
Code:
awk '
BEGIN {	FS = OFS = "|"
}
NR == 1 {
	#print	# Header is no longer desired.
	next
}
{	IX = $1 OFS $2 OFS $3 OFS $4
	n1[IX] = n1[IX] OFS $5
	n2[IX] = n2[IX] OFS $6
	# Accumulate field 7 & 8 totals.
	s1[IX] += $7
	s2[IX] += $8
}
END {	for(IX in n1)
		printf("%s%s%s|%d|%d\n", IX, n1[IX], n2[IX], s1[IX], s2[IX])
}' file2

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Retrieve 5th Field to Last Field !!

I have a script which retrieves certain fields from a text file using awk. The delimiter used is white space. cat /home/eis/boss/OPS|while read LINE do crdno=`echo $LINE | awk '{print $1}'` atm=`echo $LINE | awk '{print $2}'` seq=`echo $LINE | awk '{print $3}'` amount=`echo $LINE | awk... (3 Replies)
Discussion started by: jobbyjoseph
3 Replies

2. 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

3. Shell Programming and Scripting

Get 4 character each from 2 different fields concatenate and add as a new field

Hi, I have a huge text file. It looks like abcde bangalo country 12345 lastfield i want to get first 3 characters from field1 and first 3 characters from field 2 and insert the result as a new field. example the result should be: abcde bangalo abcban country 12345 lastfield Please... (4 Replies)
Discussion started by: ajithshankar@ho
4 Replies

4. Shell Programming and Scripting

concatenate consecutive field values

Hi, I have a file like this A Bob A Sam A John B David C Paul C Sandra If the consecutive field values in column one is same, then concatenate the corresponding strings. So, I need an output like this, A Bob_Sam_John B David C Paul_Sandra I usually work with excel but... (3 Replies)
Discussion started by: polsum
3 Replies

5. 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

6. Shell Programming and Scripting

Concatenate last field values for all occurences

Hello all, Maybe you can help me with an awk script to get what I need. I have the input file with format below: REQUEST|79023787741690|738227864597|985 REQUEST|79024002151717|738229423534|985 REQUEST|79024002151717|738229423534|*985 NDS-REQUEST|79024002151717|738229423534 ... (4 Replies)
Discussion started by: Ophiuchus
4 Replies

7. UNIX for Dummies Questions & Answers

How to sort the 6th field of tab delimited files?

Here's a sample of the data: NAME BIRTHDAY SEX LOCATION AGE ID Jim 05/11/1986 M Japan 27 86 Rei 08/25/1990 F Korea 24 33 Jane 02/24/1985 F India 29 78 I've been trying to sort files using the... (8 Replies)
Discussion started by: maihani
8 Replies

8. Shell Programming and Scripting

How to remove alphabets/special characters/space in the 5th field of a tab delimited file?

Thank you for 4 looking this post. We have a tab delimited file where we are facing problem in a lot of funny character. I have tried using awk but failed that is not working. In the 5th field ID which is supposed to be a integer only of that file, we are getting corrupted data as below. I... (12 Replies)
Discussion started by: Srithar
12 Replies

9. Shell Programming and Scripting

Trying to get 5th field from ls -l output

Bash Shell/Oracle Linux 6.4 Following is an ls -lh output. Files which are equal to or higher than 1Gigabytes will displayed with G in the 5th column of the output. I am trying to find all files which are equal to or higher than 1G File sizes are shown in the 5th column. So, I tried cut -d'... (7 Replies)
Discussion started by: John K
7 Replies

10. UNIX for Dummies Questions & Answers

Display latest record from file based on multiple columns combination

I have requirement to print latest record from file based on multiple columns combination. EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/16/2015 100004 03/16/2015 100005 001 EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/18/2015 140003 03/18/2015 140004 001 EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/18/2015 220006... (1 Reply)
Discussion started by: tmalik79
1 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 05:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy