Sponsored Content
Top Forums Shell Programming and Scripting Count the number of string occurrences to display 0 entries in output Post 303002761 by RudiC on Thursday 31st of August 2017 06:39:15 PM
Old 08-31-2017
Not understanding what you're doing in your code, I guess that this might come close to what you want:
Code:
awk 'NR == FNR {S[$1]; next} $1 in S {S[$1]++} {T[$1]} END {for (s in S) print S[s], s; for (t in T) print 0, t}' file1 file2
1 XXX200B07Y01
 XXX200B08Y01
7 XXX200B02Y01
6 XXX200B03Y01
3 XXX200B05Y01
0 XXX200E07Y01
0 XXX200D07Y01
0 XXX200B07Y01
0 XXX202B01
0 XXX200B10Y1
0 XXX202B02
0 XXX202B03
0 XXX200E10Y01
0 XXX200D10Y01
0 XXX200E30Y01
0 XXX200D30Y01
0 XXX200B30Y01
0 XXX203B02
0 XXX203B03
0 XXX200B02Y01
0 XXX200D02Y01
0 XXX203C01
0 XXX203C02
0 XXX200B03Y01
0 XXX200D03Y01
0 XXX200E05Y01
0 XXX200B05Y01
0 XXX200D05Y01
0 XXX200C02
0 XXX201B01
0 XXX201B02
0 XXX201B03

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to count number of occurrences of a "|" from a variable?

I have a variable, var="some1|some2|some3" I want to know how many "|" are in $var. When I say echo $var | grep -c '|' I am getting only 1 :confused: :confused: :confused: ? (4 Replies)
Discussion started by: jingi1234
4 Replies

2. Programming

output the letters of the alphabet with the number of occurrences

hi, I'm trying to create a program that will read a file and then check the file for each letter of the alphabet and then output the letter and the number of times it appears in the file, into a new file... this is what i have so far but it's not working.. if anyone could help that would be nice!... (10 Replies)
Discussion started by: svd
10 Replies

3. Shell Programming and Scripting

Count the number of occurrences of the word

I am a newbie in UNIX shell script and seeking help on this UNIX function. Please give me a hand. Thanks. I have a large file. Named as 'MyFile'. It was tab-delmited. I am told to write a shell function that counts the number of occurrences of the ord “mysring” in the file 'MyFile'. (1 Reply)
Discussion started by: duke0001
1 Replies

4. Shell Programming and Scripting

Count the number of occurrences of a pattern between each occurrence of a different pattern

I need to count the number of occurrences of a pattern, say 'key', between each occurrence of a different pattern, say 'lu'. Here's a portion of the text I'm trying to parse: lu S1234L_149_m1_vg.6, part-att 1, vdp-att 1 p-reserver IID 0xdb registrations: key 4156 4353 0000 0000 ... (3 Replies)
Discussion started by: slipstream
3 Replies

5. Shell Programming and Scripting

Help with Unix and Awk to count number of occurrences

Hi, I have a file (movies.sh), this file contains list of movies such as I want to redirect the movies from movies.sh to file_to_process to allow me process the file with out losing anything. I have tried Movies.sh >> file_to_process But I want to add the row number to the data... (2 Replies)
Discussion started by: INHF
2 Replies

6. Shell Programming and Scripting

How to search number of occurrences of a particular string in a file through vi editor?

i have one file, i am doing 'vi Filename' now i want to search for particular string and i want to know how many times that string occurs in whole file (5 Replies)
Discussion started by: sheelsadan
5 Replies

7. Shell Programming and Scripting

awk Group By and count string occurrences

Hi Gurus, I'm scratching my head over and over and couldn't find the the right way to compose this AWK properly - PLEASE HELP :confused: Input: c,d,e,CLICK a,b,c,CLICK a,b,c,CONV c,d,e,CLICK a,b,c,CLICK a,b,c,CLICK a,b,c,CONV b,c,d,CLICK c,d,e,CLICK c,d,e,CLICK b,c,d,CONV... (6 Replies)
Discussion started by: Royi
6 Replies

8. Shell Programming and Scripting

How to count number of characters of wc -l output?

I want count number of characters / find the length of the 'wc -l' output This is the command bash-3.2$ gzcat /home/sid/file1.dat |wc -l 830752 So final out I want is 6 i.e lenght of 830752 I tried with awk bash-3.2$ gzcat /home/sid/file1.dat |wc -l | awk '{print length ($0)... (3 Replies)
Discussion started by: sidnow
3 Replies

9. Shell Programming and Scripting

Extract count of string in all files and display on date wise

Hi All, hope you all are doing well! I kindly ask you for shell scripting help, here is the description: I have huge number of files shown below on date wise, which contains different strings(numbers you can say) including 505001 and 602001. ... (14 Replies)
Discussion started by: VasuKukkapalli
14 Replies

10. UNIX for Beginners Questions & Answers

awk or sed script to count number of occurrences and creating an average

Hi Friends , I am having one problem as stated file . Having an input CSV file as shown in the code U_TOP_LOGIC/U_HPB2/U_HBRIDGE2/i_core/i_paddr_reg_2_/Q,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0... (4 Replies)
Discussion started by: kshitij
4 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 01:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy