Sponsored Content
Top Forums Shell Programming and Scripting Help with Unix and Awk to count number of occurrences Post 302592709 by INHF on Tuesday 24th of January 2012 03:45:53 PM
Old 01-24-2012
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
Quote:
Movie Year
Absence of Malice 1981
The Adventures of Robin Hood 1938
Adam's Rib 1949
Adaptation 2002
The Adjuster 1991
The Adventures of Robin Hood 1938
Affliction 1998
Adaptation 2002
Adaptation 2002
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
Code:
Movies.sh >> file_to_process

But I want to add the row number to the data going to file to process. Like in AWK NR
Also I would like to process the (file_to_process) to get the number of occurrences for each movie for example
Quote:
Movie year number of occurrences
Adaptation 2002 3
As I don't want to same movie printed again and again.

will anyone be able to help with this?
 

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

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

4. Shell Programming and Scripting

Count occurrences in awk

Hello, I have an output from GDB with many entries that looks like this 0x00007ffff7dece94 39 in dl-fini.c 0x00007ffff7dece97 39 in dl-fini.c 0x00007ffff7ab356c 50 in exit.c 0x00007ffff7aed9db in _IO_cleanup () at genops.c:1022 115 in dl-fini.c 0x00007ffff7decf7b in _dl_sort_fini (l=0x0,... (6 Replies)
Discussion started by: ikke008
6 Replies

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

6. Shell Programming and Scripting

Speed : awk command to count the occurrences of fields from one file present in the other file

Hi, file1.txt AAA BBB CCC DDD file2.txt abc|AAA|AAAabcbcs|fnwufnq bca|nwruqf|AAA|fwfwwefwef fmimwe|BBB|fnqwufw|wufbqw wcdbi|CCC|wefnwin|wfwwf DDD|wabvfav|wqef|fwbwqfwfe i need the count of rows of file1.txt present in the file2.txt required output: AAA 2 (10 Replies)
Discussion started by: mdkm
10 Replies

7. Shell Programming and Scripting

Count occurrences in first column

input amex-11 10 abc amex-11 20 bcn amed-12 1 abc I tried something like this. awk '{h++}; END { for(k in h) print k, h }' rm1 output amex-11 1 10 abc amex-11 1 20 bcn amed-12 2 1 abc Note: The second column represents the occurrences. amex-11 is first one and amed-12 is the... (5 Replies)
Discussion started by: quincyjones
5 Replies

8. Shell Programming and Scripting

Count the number of string occurrences to display 0 entries in output

Hello Friends, Can somebody assist an issue I am having? I have a separate file with a list of account ids XXX200B02Y01 XXX200B03Y01 XXX200B05Y01 XXX200B07Y01 XXX200B08Y01 I call the file, and run an egrep against a directory and logfiles AccountID=$(cat... (2 Replies)
Discussion started by: liketheshell
2 Replies

9. 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
.::SWF::MovieClip(3pm)					User Contributed Perl Documentation				    .::SWF::MovieClip(3pm)

NAME
SWF::MovieClip - MovieClip Class SYNOPSIS
use SWF::MovieClip; my $movieclip = new SWF::MovieClip(); DESCRIPTION
SWF::MovieClip allows you to add animated objects to your Flash movies. METHODS
$mc= new SWF::MovieClip() Returns an SWF::MovieClip object. $item = $mc->add($swfobject) When you add following types of objects to the $mc they will return a SWF::DisplayItem: SWF::Button SWF::PrebuiltClip (a whole external swf file) SWF::MovieClip (you can nest them like a tree) SWF::Shape SWF::Text SWF::TextField SWF::VideoStream [ToDo: to be verified: When you add a SWF::Sound the return value is a SWF::SoundInstance: $si = $mc->add($sound); ] $si = $mc->startSound($sound) Starts making noise and returns an object of SWF::SoundInstance class. $mc->stopSound($sound) Stops sound started by startSound() method. $mc->remove($di) Removes SWF::DisplayItem $di from the display list. $mc->nextFrame() Move to the next frame in the timeline of SWF::MovieClip $mc $mc->setNumberOfFrames($i) $mc->setFrames($i) Sets total number of $mc frames to $i This is an optional autofiller, e.g. when you want to be sure that 2 different movieclips have 100 frames when playing, but the number of nextFrame() calls in these 2 movieclips is unknown or dynamic (dependent on data from databases, whatever). By default a movieclip the number of frames in the timeline is how often you called $mc->nextFrame for this clip. $mc->labelFrame($name) Sets frame name to $name. You are then able to access this frame by name in ActionScript, not just by frame number. $mc->setScalingGrid($x, $y, $w, $h) This function (available from SWF>=8) sets a 9 slice scaling grid: 1 2 3 4 5 6 7 8 9 X, y, w and h define a rectangle, which is the dimension of the center slice(5). All other slices are determined out of the characters bounds and the defined rect. While slice 5 is scaled vertical and horizontal, slice 2 and 8 are only scaled horizontal. Slice 4 and 6 only vertical. The 4 corner slices are not scaled (1, 3, 7, 9). [ToDo: to be verified] $mc->removeScalingGrid() Removes scaling grid rectangles. $mc->addInitAction($action) Adds an initial ActionScript block to MovieClip $mc. These actions are executed before the MovieClip is available as a script object. [ToDo: to be verified] $mc->setSoundStream($sound, $rate, [$skip]) Includes streaming sound to a movie. [ToDo: add more doc and a demo here.] AUTHOR
Soheil Seyfaie (soheil@netcom.ca) Peter Liscovius see AUTHORS of ming distribution (ming.sf.net) SEE ALSO
SWF::DisplayItem for how you can modify the instances in a SWF::MovieClip or SWF::Movie SWF, SWF::Action, SWF::InitAction, SWF::Button, SWF::Movie, SWF::Shape, SWF::Sound, SWF::SoundStream, SWF::Text, SWF::TextField, SWF::VideoStream perl v5.14.2 2011-10-26 .::SWF::MovieClip(3pm)
All times are GMT -4. The time now is 03:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy