Sponsored Content
Top Forums Shell Programming and Scripting grep all records in a file and get a word count -perl Post 302167169 by jim mcnamara on Wednesday 13th of February 2008 04:27:25 PM
Old 02-13-2008
wc -l filename gives a record count for a file
in perl
Code:
$variable = `wc -l filename`

wc -c counts the words in a file. It is hard to see which one you want.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies

2. UNIX for Dummies Questions & Answers

Count records in a zip file

Hello, I searched the forums on the keywords in the title I used above, but I did not find the answer: Is it possible to count records in a .zip file on an AIX machine if i don't have pkunzip installed? From all the research I'm reading in google and the reading of pkunzip in Unix.com,... (3 Replies)
Discussion started by: tekster757
3 Replies

3. UNIX for Dummies Questions & Answers

if clause with grep and word count

I've got following script that I thought would only email me when the if clause finds the grep. But it emails me anyway (with an empty file) even if the grep doesn't return anything. What should the line be? if then grep -l 'unique constraint' $LOGDIR/archive_active* >... (3 Replies)
Discussion started by: Meert
3 Replies

4. UNIX for Dummies Questions & Answers

Grep specific records from a file of records that are separated by an empty line

Hi everyone. I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this: ID: 20 Name: X Age: 19 ID: 21 Name: Z ID: 22 Email: xxx@yahoo.com Name: Y Age: 19 I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies

5. UNIX for Dummies Questions & Answers

grep word count

How do I do a grep wc that counts occurences of two or more different strings? If I have string1 two times and string2 three times, how do I use wc to get the number 5? (1 Reply)
Discussion started by: locoroco
1 Replies

6. Shell Programming and Scripting

Perl code- word count problem

Hi, I am having .csv files contains some row - Info: Value of field name 'SecurityExchange' is not supported ","Original Order Tuple Please see the below perl code carefully- /Info: (+),Original (\w+) Tuple/ and do { ($category, $type) = ($1, $2); if($type eq 'Execution')... (1 Reply)
Discussion started by: pspriyanka
1 Replies

7. UNIX for Dummies Questions & Answers

word count with grep

Hi, It is very interesting to learn the unix, i just struck with a doubt like i have below content in my file xyz xyz xyz xyz i just want know the word count by using grep -wc 'xyz' <filename>, but it is giving 3 instead of 4.So i understood that it is showing matched line numbers count... (2 Replies)
Discussion started by: vmachava
2 Replies

8. Shell Programming and Scripting

perl count lines with certain word int

Hi Guys I have a text file that contains the message like this /var/log/messages.all-20120401: Mar 26 12:12:23 brent kernel: NVRM: Xid (0003:00): 43, 0005 00009097 00000000 00000000 00001b0c 1000f010 /var/log/messages.all-20120401: Mar 27 20:42:40 brent kernel: NVRM: Xid (0003:00): 43,... (4 Replies)
Discussion started by: ab52
4 Replies

9. Shell Programming and Scripting

Use GREP to count number of records and place it in a variable

I am trying to count the number of records from different files using grep, and then place the result in a separate variable for each file, so at the end of my shell script, I can sum all the variables and check if the number of records are equal to what I was expecting. It is weird butwc -ldoes... (2 Replies)
Discussion started by: dhruuv369
2 Replies

10. UNIX for Beginners Questions & Answers

UNIX script to check word count of each word in file

I am trying to figure out to find word count of each word from my file sample file hi how are you hi are you ok sample out put hi 1 how 1 are 1 you 1 hi 1 are 1 you 1 ok 1 wc -l filename is not helping , i think we will have to split the lines and count and then print and also... (4 Replies)
Discussion started by: mirwasim
4 Replies
cord2(1)						      General Commands Manual							  cord2(1)

Name
       cord2 - rearranges basic blocks in an executable file to facilitate better cache mapping.

Syntax
       cord2 [-v] [-o outfile] [-c cachewords] [-d] [-b bridge_limit] [-n] [-A addersfile] [[-C countsfile] ...] obj

Description
       The  cord2  command extracts basic blocks from a program and deposits them in a new area in the text, making jumps to and from that area as
       necessary.  By separating the basic blocks, you can reduce instruction cache miss rates.  The cord2 command takes the  output  of  a  pixie
       profiling run as input (see

       The executable object file has the suffix obj.  The cord2 command only requires one addersfile; it creates the filename by appending .Bbad-
       drs to the obj filename if none is specified with -A. Multiple counts files can be specified from many runs with multiple -C arguments.	If
       none are specified, cord2 creates the counts filename by appending .Counts to the obj name.

       Multiple  counts  files are added together into an internal counts array represented with C double-type elements. The counts array elements
       contain the density of a block or cycles/byte.  If you specify -n, then the counts are normalized  so  that  each  counts  array  entry	is
       cycles/totalcycles.   When one counts file is specified, the default is to favor small blocks; -n negates that.	When many counts files are
       specified, -n also negates favoring one counts file. This is because its totalcycles may exceed the totalcycles of another counts file.

       The cord2 command determines which basic blocks to insert by sorting the counts array and collecting the blocks	with  the  highest  counts
       that can fit into the new area.	The cord2 command may skip over huge blocks that do not fit at the end of the new area.

       Once  the  blocks are determined, they are inserted into the new area, and their original location is modified to jump to the new area.	At
       the end of each block in the new area, a jump is added  back  to  the  original	block's  subsequent  or  fall-through  location,  and  the
       branch/jump  target  (if necessary).  Both entering and exiting the new area is optimized to take advantage of other blocks in the new area
       and jump delay slots.

       Often, there may be one or more fall-through blocks of a block in the new area which are small, hardly ever used, and not in the new  area.
       If  the	block  following  these  fall-through blocks is in the new area, the fall-through blocks are called bridge blocks.  It may be more
       costly to generate jumps to and from bridge blocks rather than to simply copy them.

       The cord2 command allows you to specify that bridge blocks be added to the new area if they total less than the	bridge_limit  instructions
       between	two  new-area blocks. You can specify the bridge_limit with -b; the default is zero.  Bridge blocks can bump blocks out of the new
       area that might normally fit into it.

       Because the cord2 command works from profile output, the resulting binary is data dependent. In other words, it may perform  well  only	on
       the  same input data that generated the profile information, and may perform worse than the original binary on other data.  Furthermore, if
       the hot areas in the cache do not fit well into one cachepage, performance can degrade.

Options
       The cord2 command also accepts these options:

       -d   Fill the delay slots with nops only when adding jumps to and from the new area.

       -v   Print verbose information. This includes statistics about the cord2 process.

       -v -v
	    Print all of the -v information, but include detailed disassemblies of the code moved, changed, and generated by cord2.

       -c cachewords
	    Specify the number of words in the cache of the machine on which you want to execute.  This is actually the size of the new area.  The
	    cachesize  may be a misnomer, as you can specify a size other than your machine's cache size; however, it is probably the correct num-
	    ber.

       -o outputfile
	    Specify the output file.  If it is not specified, the default is a.out.cord2.

Restrictions
       The cord2 command adds the new area to the end of text so any program using the etext symbol may not work.  See

See Also
       pixie(1), cord(1)

								       RISC								  cord2(1)
All times are GMT -4. The time now is 05:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy