Sponsored Content
Top Forums Shell Programming and Scripting Nawk One Liner to Count Field Combinations Post 302772707 by he204035 on Tuesday 26th of February 2013 02:01:35 PM
Old 02-26-2013
I cannot upload a sample text file because it has customer proprietary infomation. Each line has 115 fields ($1 - $115) but fields $5 and $11 would look like so:
Code:
4012 1070397
4012 1070397
4014 1070397
4014 1070397
4014 1070398
4014 1070398
4018 1070398
40184 1070398

And I would like the output to say something along the lines of "4012 1070397" combination happened X times, "4014 1070397" combination happened y times, etc.

---------- Post updated at 01:01 PM ---------- Previous update was at 12:46 PM ----------

I can't believe that was the only problem! Maybe I dont suck as bad as I thought, lol.

Thanks so much!

:-)

Last edited by Franklin52; 02-27-2013 at 03:20 AM.. Reason: Code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

append field to file(nawk)

I have two files. File A and File B. File A has two fields separated by comma 352020252365988, 652020100572356 546876543215667, 652065465654686 ... File B has many Fields separate by spaces Date Name 352020252365988 Reference Date2 Name2 546876543215667 Reference I want to... (4 Replies)
Discussion started by: axl
4 Replies

2. Shell Programming and Scripting

I need help counting the fields and field separators using Nawk

I need help counting the fields and field separators using Nawk. I have a file that has multiple lines on it and I need to read the file 1 at a time and then count the fields and field separators and then store those numbers in variables. I then need to delete the first 5 fields and the blank... (3 Replies)
Discussion started by: scrappycc
3 Replies

3. Shell Programming and Scripting

nawk-how count the number of occurances of a pattern, when don't know the pattern

I've written a script to count the total size of SAN storage LUNs, and also display the LUN sizes. From server to server, the LUNs sizes differ. What I want to do is count the occurances as they occur and change. These are the LUN sizes: 49.95 49.95 49.95 49.95 49.95 49.95 49.95 49.95... (2 Replies)
Discussion started by: cyber111
2 Replies

4. UNIX for Dummies Questions & Answers

Count of Field for Non-Empty

Hi Guys, I wanted to count the number of records for a particular field of a file. whose fields are separated by comma"," I fI use this command. cat "filename" cut -sd "," -f13 | wc -l This shows all the lines count including the blank values for the field number 13. I wanted to count... (2 Replies)
Discussion started by: Swapna173
2 Replies

5. Shell Programming and Scripting

Count number of occurences of a character in a field defined by the character in another field

Hello, I have a text file with n lines in the following format (9 column fields): Example: contig00012 149606 G C 49 68 60 18 c$cccccacccccccccc^c I need to count the number of lower-case and upper-case occurences in column 9, respectively, of the... (3 Replies)
Discussion started by: s052866
3 Replies

6. Shell Programming and Scripting

awk (nawk) field separator

Hi; i have a file and i want to get; - If the last word in line 14 is NOT equal to "Set."; then print 2nd, 3rd, 4th and 5th values of 3rd line. and my code is: nawk 'NR==14 {if ($NF!="Set.") (NR==3{print $2,$3,$4,$5}) }' file.txt but no result?? :confused::(:confused::( (4 Replies)
Discussion started by: gc_sw
4 Replies

7. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

8. UNIX for Dummies Questions & Answers

Generating all possible combinations of values in field 1 (awk)

Input: A|1 B|2 C|3 D|4 Output: A+B|3 A+C|4 A+D|5 B+C|5 B+D|6 C+D|7 A+B+C|6 A+B+D|7 A+C+D|8 B+C+D|9 A+B+C+D|10 I only managed to get the output for pairs of $1 values (i.e. combination of length 2): (4 Replies)
Discussion started by: beca123456
4 Replies

9. Shell Programming and Scripting

FYI - gotcha when using a nawk one liner to convert a processes RSS to MB

I used the following one liner (obtained from an old thread on this site) to look for RSS size of a process and convert it to Mb (I am using process nfsmapid as an example): ps -eo rss,args | nawk 'END { print s/1024, "Mb" } /nfsmapid/ { s += $1 }' I found that the RSS Mb displayed was always... (1 Reply)
Discussion started by: thaebich
1 Replies
tplot(1)							   User Commands							  tplot(1)

NAME
tplot, t300, t300s, t4014, t450, tek, ver - graphics filters for various plotters SYNOPSIS
/usr/bin/tplot [-T terminal] DESCRIPTION
tplot reads plotting instructions from the standard input and produces plotting instructions suitable for a particular terminal on the standard output. If no terminal is specified, the environment variable TERM is used. The default terminal is tek. ENVIRONMENT VARIABLES
Except for ver, the following terminal-types can be used with `lpr -g' (see lpr) to produce plotted output: 300 DASI 300 or GSI terminal (Diablo(R) mechanism). 300s | 300S DASI 300s terminal (Diablo mechanism). 450 DASI Hyterm 450 terminal (Diablo mechanism). 4014 | tek Tektronix 4014 and 4015 storage scope with Enhanced Graphics Module. (Use 4013 for Tektronix 4014 or 4015 without the Enhanced Graphics Module). ver Versatec(R) D1200A printer-plotter. The output is scan-converted and suitable input to `lpr -v'. FILES
/usr/lib/t300 /usr/lib/t300s /usr/lib/t4014 /usr/lib/t450 /usr/lib/tek /usr/lib/vplot ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
lp(1), vi(1), attributes(5) SunOS 5.11 14 Jul 1994 tplot(1)
All times are GMT -4. The time now is 10:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy