Sponsored Content
Full Discussion: awk - Number of records
Top Forums Shell Programming and Scripting awk - Number of records Post 302088057 by jim mcnamara on Friday 8th of September 2006 08:13:51 AM
Old 09-08-2006
Code:
wc -l filename | read linecnt dummy
awk -v linecnt=$linecnt '{ print linecnt  }' filename

This defines linecnt as a variable with the number of lines in the file.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Number of records in a file

hi gurus i'm trying to get the count of number of records of a file as : wc -l file1.txt iam getting the correct count by in out put i'm getting the file name too i get the output as follows "7 file1.txt" my question is how to avoid filename in the output. might be a basic... (20 Replies)
Discussion started by: sish78
20 Replies

2. Shell Programming and Scripting

loop number of records.

Initially i store some files into anothe file Y. Now i want read the contents of file Y one by one do some check on each file. i,e Open file Y (contains multiple files) First read a file , do some check on that individual file.If that file satisfies teh condition put it in another file. Now... (1 Reply)
Discussion started by: vasuarjula
1 Replies

3. Shell Programming and Scripting

Calculating number of records by field

Hi, I have CSV file which looks like below, i want to calulate number of records for each brand say SOLO_UNBEATABLE E and SOLO_UNBEATABLE F combined and record count is say 20 . i want to calculate for each brand, and here only first record will have all data and rest of record for the brand... (2 Replies)
Discussion started by: raghavendra.cse
2 Replies

4. Shell Programming and Scripting

Getting number of records from a table

I am doing a loading process. I am loading data from a Oracle source to Oracle target. For example there is an SQL statement: Insert into emp_1 Select * from emp_2 where deptno=20; In this case my source is emp_2 and loading into my target table emp_1. This process is automated. Now I... (3 Replies)
Discussion started by: karthikkasarla
3 Replies

5. Shell Programming and Scripting

Need the line number of failed records

Hi awk Gurus, I have file as below : file1.txt 7000,2,1,6 7001,2,1,7 7002,2,1,6 7003,1,2,1 file2.txt 7000,john,2,0,0,1,6 7000,john,2,0,0,1,7 7000,john,2,0,0,1,8 7000,john,2,0,0,1,9 7001,elen,2,0,0,1,7 7002,sami,2,0,0,1,6 7003,mike,1,0,0,2,1 (13 Replies)
Discussion started by: arunshankar.c
13 Replies

6. Shell Programming and Scripting

AWK: Cannot read Number of records greater than 1(NR>1)

Hi all, I have a tab-delimited text file of size 10Mb. I am trying to count the number of lines using, grep -c . sample.txtor wc -l < sample.txt or awk 'END {print NR}' sample.txtAll these commands shows the count as 1, which means they are reading only the first header line of the file.... (3 Replies)
Discussion started by: mehar
3 Replies

7. Shell Programming and Scripting

AWK print number of records, divide this number

I would like to print the number of records of 2 files, and divide the two numbers awk '{print NR}' file1 > output1 awk '{print NR}' file2 > output2 paste output1 output2 > output awl '{print $1/$2}' output > output_2 is there a faster way? (8 Replies)
Discussion started by: programmerc
8 Replies

8. Shell Programming and Scripting

Compare two files with different number of records and output only the Extra records from file1

Hi Freinds , I have 2 files . File 1 |nag|HYd|1|Che |esw|Gun|2|hyd |pra|bhe|3|hyd |omu|hei|4|bnsj |uer|oeri|5|uery File 2 |nag|HYd|1|Che |esw|Gun|2|hyd |uer|oi|3|uery output : (9 Replies)
Discussion started by: i150371485
9 Replies

9. Shell Programming and Scripting

gzcat number of records

Hey guys, I want to do something quite simple but I just can't no matter what I try. I have a large file and i usually just: gzcat test.gz | nohup /test/this-script-does-things-to-the-records.pl -> /testdir/tmp_test.txt But now I need to do it only for the first 100k records. I sure... (7 Replies)
Discussion started by: sg3
7 Replies

10. UNIX for Dummies Questions & Answers

Make all records with the same number of fields (awk)

Hi, input: AA|BB|CC DD|EE FF what I am trying to get: AA|BB|CC DD|EE| FF|| I tried to create first an UDF for printing repeats, but I think I have an issue with my END section or my array: function repeat(str, n, rep, i) { for(i=1 ;i<n;i++) rep=rep str return rep } ... (6 Replies)
Discussion started by: beca123456
6 Replies
GENDERS_LOAD_DATA(3)						    LIBGENDERS						      GENDERS_LOAD_DATA(3)

NAME
genders_load_data - read and parse a genders file SYNOPSIS
#include <genders.h> int genders_load_data(genders_t handle, const char *filename); DESCRIPTION
genders_load_data() read and parses the genders file indicated by filename. If filename is NULL, genders_load_data() will attempt to read and parse the default genders file defined by DEFAULT_GENDERS_FILE. handle is a genders handle created by genders_handle_create(3). After genders_load_data() is called, information about the genders file is stored in the genders handle passed in. This information is used by other genders C API functions. All future use of handle with other genders C API functions will be directly associated with the genders file indicated by filename (or the default genders file if filename is NULL). RETURN VALUES
On success, 0 is returned. On error, -1 is returned, and an error code is returned in handle. The error code can be retrieved via gen- ders_errnum(3) , and a description of the error code can be retrieved via genders_strerror(3). Error codes are defined in genders.h. ERRORS
GENDERS_ERR_NULLHANDLE The handle parameter is NULL. The genders handle must be created with genders_handle_create(3). GENDERS_ERR_OPEN The genders file indicated by filename cannot be opened for reading. GENDERS_ERR_READ Error reading the genders file indicated by filename. GENDERS_ERR_PARSE The genders file indicated by filename is incorrectly formatted. GENDERS_ERR_ISLOADED genders_load_data(3) has already been called with handle. GENDERS_ERR_OVERFLOW A line in the genders database exceeds the maximum allowed length. GENDERS_ERR_OUTMEM malloc(3) has failed internally, system is out of memory. GENDERS_ERR_MAGIC handle has an incorrect magic number. handle does not point to a genders handle or handle has been destroyed by genders_han- dle_destroy(3). GENDERS_ERR_INTERNAL An internal system error has occurred. FILES
/usr/include/genders.h SEE ALSO
libgenders(3), genders_handle_create(3), genders_handle_destroy(3), genders_errnum(3), genders_strerror(3) LLNL
August 2003 GENDERS_LOAD_DATA(3)
All times are GMT -4. The time now is 07:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy