Sponsored Content
Top Forums Shell Programming and Scripting count lines in file to variable Post 302566765 by ahamed101 on Friday 21st of October 2011 05:19:05 AM
Old 10-21-2011
You mean something like this?

Code:
line_no=$(awk '{x++} END {print x}' filename)
echo $line_no

--ahamed

PS : Please use code tags. Thank you for your co-operation.

Last edited by ahamed101; 10-21-2011 at 06:25 AM..
This User Gave Thanks to ahamed101 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

setting file count to a variable

Hey guys. My goal here is to count the number of .dat files in in a directory(28 files). If 28 files exist I am ok. Having trouble doing this. Any help would b e greatly appreciated. #!/usr/bin/ksh #============================================================================= ### Define local... (3 Replies)
Discussion started by: ecupirate1998
3 Replies

2. Shell Programming and Scripting

Count number of lines in Binary file

Hi Friends Please help me out to count number of lines in binary file. It gives some wrong(less) using wc -l. Is there any other way to count lines of binary file. Thanks. (3 Replies)
Discussion started by: vanand420
3 Replies

3. Shell Programming and Scripting

count lines of file

dear all, i want to count the lines of a flat(text) file using awk.i have tried with {print NR} but its taking lot of time for a big file like 2GB file size. so i want better efficiency...so can any body please help me with some other and better awk code? Regards, Pankaj (15 Replies)
Discussion started by: panknil
15 Replies

4. Programming

to count the number of commented lines in a file

can someone guide me how to have a C pgm to count the number of commented lines? (3 Replies)
Discussion started by: naan
3 Replies

5. Shell Programming and Scripting

Count lines between two patterns inside a file

Hi, Im doing a script to find the number of lines included inside a file newly. These lines are in between #ifdef FLAG1 and #else or #endif or #else and #endif. I tried like this, awk '/#ifdef Flag1/,/#e/{print}' aa.c | wc -l awk '/#ifndef Flag1/,/#endif/{print}' aa.c | awk... (6 Replies)
Discussion started by: priyadarshini
6 Replies

6. UNIX for Dummies Questions & Answers

Count of Number of Lines in a File

Dear Members, I want to count the number of lines in a file; for that i am using the following command : FILE_LINE_COUNT=`wc -l $INT_IN/$RAW_FILE_NAME` if i do an echo on FILE_LINE_COUNT then i get 241 /home/data/testfile.txt I don't want the directory path to be displayed. Variable... (1 Reply)
Discussion started by: sandeep_1105
1 Replies

7. Shell Programming and Scripting

Trying to do a count on multiple lines in a file

Guys I am having a problem with being able to do a count of entries in a file. What I am trying to get a count of the total number of members that are listed in the files. So I need to pull the number of the lines after members. I tried using sed but it only seems to count the first... (7 Replies)
Discussion started by: scottzx7rr
7 Replies

8. Solaris

WC -l does not count all the lines in a file? HELP

I have a file that I need to merge with another like file. Normally I remove the trailer reocrd and merge the file and update the trailer record of the second file. I did a WC -l on the first file before I removed the trailer record, and again afterwards. The count came back the same. I opened the... (6 Replies)
Discussion started by: Harleyrci
6 Replies

9. Shell Programming and Scripting

If file exists count lines

Hello, Currently I have: FILE=/home/file.txt if ; then echo "File $FILE exists" else echo "File $FILE does not exist" fi exit I would like to make it such that if the file *does* exist, it performs a wc -l count of the file and then if the count is greater than 3 performs... (3 Replies)
Discussion started by: holyearth
3 Replies

10. Shell Programming and Scripting

Getting file count in a variable

Hi All I am checking for the presence of certain no of files in a directory. Only if the required no of files are present should I continue with my processing. For e.g. in the temp directory below, there are 4 files of the format sample_aa(bb)(cc)(dd)_test. I need to check the count of these... (17 Replies)
Discussion started by: swasid
17 Replies
etags(1)						      General Commands Manual							  etags(1)

NAME
etags - Generates a tags file for the emacs or mule editor SYNOPSIS
etags [-a | -append] [-C | -c++] [-D | -no-defines] [-i tagsfile2 | -include=tagsfile2] [-o tagsfile | -output=tagsfile] [-S | -ignore-indentation] [-H | -help] [-V | -version] filename... OPTIONS
Appends output to an existing vi-format tags file. (Supports operation of the emacs editor in vi mode.) Treats files with or extensions as C++, rather than C, code. The etags command always treats files with extensions as C++ code. Does not create tag entries for C preproces- sor definitions. If many header files are tagged, using this option may make the tags file much smaller. Includes a note in the output tags file to indicate that, when searching for a tag, one should also consult the tagsfile2 tags file. Explicitly names the output tags file; overrides the default name, which is TAGS. Instructs etags not to rely on indentation to determine nesting level. Currently, this means not to assume that a closing brace in the first column is the final brace in a function or structure definition in C or C++ code. Prints usage information. Prints the current version of the program. OPERANDS
Specifies the input language source file, or files, to be processed. DESCRIPTION
The etags program creates a tag table file in a format understood by the emacs editor. The program understands the syntax of C, C++, For- tran, Pascal, and Lisp source files. It reads the source files specified on the command line and writes a tag table (named TAGS by default) in the working directory. Recognition of the language used in an input file is based on the filename extension and file contents; there are no options for specifying the language. NOTES
The etags program is software distributed by the Free Software Foundation. SEE ALSO
Commands: emacs(1), mule(1) etags(1)
All times are GMT -4. The time now is 02:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy