Count of rows starting with 01 in a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Count of rows starting with 01 in a file
# 1  
Old 11-20-2011
Count of rows starting with 01 in a file

Hi
I am very new to unix and please help me in solving the below problem
I have a file with 50000+ rows. Each row(line) start with 01 or 02 or 03.
Now i have to get the count of rows starting with 01 only,

Thanks in advance
# 2  
Old 11-20-2011
Code:
grep -c '^01'  inputfilename

This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 11-20-2011
Thanks lot. it worked
# 4  
Old 11-21-2011
Code:
awk '/^01/{a+=1}END{print a}' inputfilename

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reseting row count every given number of rows

I have a file with 48 rows. I am counting 6 rows and adding 6 to that number and repeating the operation, and then output the value in column 1. For the second column, I would like to get sort of a binary output (1s and 2s) every 3rd row. This is what I have: awk '{print ++src +... (1 Reply)
Discussion started by: Xterra
1 Replies

2. Shell Programming and Scripting

Count the words starting with 3-

OS : Oracle Linux 6.5 Shell : bash I have a file whose contents look like below. I want to count the number of occurences of strings starting with 3-. How can I do this ? I couldn't wordwrap the below line. Hence it looks long. '3-90892405251', '3-90892911050', '3-90893144163',... (8 Replies)
Discussion started by: John K
8 Replies

3. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

4. UNIX for Dummies Questions & Answers

Script to count number of rows

Hi, I need a solaris shell script to read multiple files and count number of unique name rows(strings) from those files. The input and output should be like this Input: file 1 abc cde abc ... (9 Replies)
Discussion started by: ssk250
9 Replies

5. Shell Programming and Scripting

Extract and count number of Duplicate rows

Hi All, I need to extract duplicate rows from a file and write these bad records into another file. And need to have a count of these bad records. i have a command awk ' {s++} END { for(i in s) { if(s>1) { print i } } }' ${TMP_DUPE_RECS}>>${TMP_BAD_DATA_DUPE_RECS}... (5 Replies)
Discussion started by: Arun Mishra
5 Replies

6. Shell Programming and Scripting

Deleting rows starting with a character and word

Hi, I have multiple files of same format and I want to delete the lines starting with # and The from all of them I am using egrep -v '^(#|$)' for # but unable to do for both # and The Please guide Thanks (12 Replies)
Discussion started by: bioinfo
12 Replies

7. UNIX for Dummies Questions & Answers

Count rows in .dat file

Could you please tell e how to find the total number of rows in a .dat file. edit by bakunin: this is exactly why in "advanced and expert" section?? I transfer this thread to "Unix for Dummies Questions and Answers" (2 Replies)
Discussion started by: Deeptanshu
2 Replies

8. Shell Programming and Scripting

Find count of rows in excel sheet in Unix

Hi, Is there a way to find the count of number of rows of a.txt please? Where a.txt is as follows: /usr/bin/uuencode /tmp/a.csv a.csv > /tmp/a.txt #a.csv is a comma separated variable file Cheers, Girish. (7 Replies)
Discussion started by: girish1428
7 Replies

9. Shell Programming and Scripting

How to count the number of files starting with a pattern in a Directory

Hi! In our current directory there are around 35000 files. Out of these a few thousands(around 20000) start with, "testfiles9842323879838". I want to count the number of files that have filenames starting with the above pattern. Please help me with the command i could use. Thank... (7 Replies)
Discussion started by: atechcorp
7 Replies

10. Shell Programming and Scripting

count numbers of matching rows and replace its value in another file

Hello all, can you help me in this problem, assume We have two txt file (file_1 and file_3) one is file_1 contains the data: a 0 b 1 c 3 a 7 b 4 c 5 b 8 d 6 . . . . and I need to count the lines with the matching data (a,b,..) and print in new file called file_2 such as the... (4 Replies)
Discussion started by: GoldenFalcon10
4 Replies
Login or Register to Ask a Question