Sponsored Content
Full Discussion: Alternative for wc -l
Top Forums Shell Programming and Scripting Alternative for wc -l Post 302462839 by methyl on Friday 15th of October 2010 07:24:25 AM
Old 10-15-2010
Quote:
awk 'END{print NR}' yourfile
Out of interest, I tried this on a 5 million record text file and the result came out as an exponential number. The result from "wc -l" was correct.
Anybody know how to get awk to count a large number of records?


@rajesh_2383
How many records in a typical file?
Are they fixed length records? If so, we could calculate the number of records from the file size.

What database engine is this? It may be quicker to write a count program in a high level language.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getopts alternative?

I have to implement switches (options) like this in my script. ./myscript -help ./myscript -dir /home/krish -all ./myscript -all getopts allows switches to have one character (like a, b, etc.). How can I customize it for handling the above situation? Or, is there any alternative to... (3 Replies)
Discussion started by: krishmaths
3 Replies

2. Shell Programming and Scripting

help with while loop or any other alternative?

i=1 while do mm=02 dd=03 yy=2008 echo "$mm$dd$yy" i=$(( i+1)) echo "$i" done whenever i execute the script above i will get the error below: syntax error at line 30: `i=$' unexpected (3 Replies)
Discussion started by: filthymonk
3 Replies

3. Shell Programming and Scripting

du alternative in perl

I have a perl script that just does a `du -sk -x` and formats it to look groovy ( the argument can be a directory but usually is like /usr/local/* ) #!/usr/bin/perl use strict; use warnings; my $sizes = `du -x -sk @ARGV | sort -n`; my $total = 0; print "MegaBytes Name\n"; for(split... (1 Reply)
Discussion started by: insania
1 Replies

4. HP-UX

alternative for egrep -o on HP-UX

Hello to all board members!! I have a problem on a HP-UX system. I should write a script. Therefore I need to search after IP addresses in the output of a command. On Debian this works: ifconfig | egrep -o "{1,3}\.{1,3}\.{1,3}\.{1,3}" The script where i need this is not ifconfig, but... (2 Replies)
Discussion started by: vostro
2 Replies

5. Shell Programming and Scripting

Alternative for ikecert

Hi Folks... Is there an alternative for ikecert(SunOS) - man info - "manipulates the machine's on-filesystem public-key certificate databases" in linux? Can we use pkcs7, pkcs8 or something like that?... I also came across ssh-keygen and ssh-keygen2... My best guess is to use ssh-certtool... (0 Replies)
Discussion started by: ahamed101
0 Replies

6. Solaris

Alternative to sshfs?

I have an automated testing script that relies on the dev box being able to see production's (NFS) share. It uses rsync and ssh to handle transfers and command execution; however, it also needs the production share mounted in order to run Perl code against it when Unix commands via ssh will not do.... (2 Replies)
Discussion started by: effigy
2 Replies

7. Solaris

vi alternative

Is there any other editor, installed by 'default' in Sparc Solaris10, besides vi? I'd like to avoid installing anything new. If not, how to make vi more user-friendly? thanks. (8 Replies)
Discussion started by: orange47
8 Replies

8. Shell Programming and Scripting

Looking for an alternative to Tcl

I've created quite a collection of tcl scripts which have buttons, radio buttons, check boxes, text fields, etc. These tcl scripts in turn call and execute several hundred sh, csh, bash, perl scripts and pass in the args based on the gui selections on the same and other redhat machines. We're... (4 Replies)
Discussion started by: scottwevans
4 Replies
MSSQL_RESULT(3) 														   MSSQL_RESULT(3)

mssql_result - Get result data

SYNOPSIS
string mssql_result (resource $result, int $row, mixed $field) DESCRIPTION
mssql_result(3) returns the contents of one cell from a MS SQL result set. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). o $row - The row number. o $field - Can be the field's offset, the field's name or the field's table dot field's name (tablename.fieldname). If the column name has been aliased ('select foo as bar from...'), it uses the alias instead of the column name. Note Specifying a numeric offset for the $field argument is much quicker than specifying a fieldname or tablename.fieldname argu- ment. RETURN VALUES
Returns the contents of the specified cell. EXAMPLES
Example #1 mssql_result(3) example <?php // Send a select query to MSSQL $query = mssql_query('SELECT [username] FROM [php].[dbo].[userlist]'); // Check if there were any records if (!mssql_num_rows($query)) { echo 'No records found'; } else { for ($i = 0; $i < mssql_num_rows($query); ++$i) { echo mssql_result($query, $i, 'username'), PHP_EOL; } } // Free the query result mssql_free_result($query); ?> The above example will output something similar to: Kalle Felipe Emil Ross Example #2 Faster alternative to above example <?php // Send a select query to MSSQL $query = mssql_query('SELECT [username] FROM [php].[dbo].[userlist]'); // Check if there were any records if (!mssql_num_rows($query)) { echo 'No records found'; } else { while ($row = mssql_fetch_array($query)) { echo $row['username'], PHP_EOL; } } // Free the query result mssql_free_result($query); ?> NOTES
Note When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than mssql_result(3). SEE ALSO
Recommended high-performance alternatives: mssql_fetch_row(3), mssql_fetch_array(3), mssql_fetch_assoc(3), mssql_fetch_object(3). PHP Documentation Group MSSQL_RESULT(3)
All times are GMT -4. The time now is 07:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy