ok, you have a file and you want to know how many lines it has right?
if you are like me, sometimes we need to know this infromation for some reason or another. well today you are in luck because you've found a cool little tutorial i wrote just to show people like you and me who are learning linux how to send or used linux shell command.
ok the command you need to use is wc
for example, if i have a file called my_text.txt and i want to know how many lines this file has, all if would have to do is send this command:
wc -l my_text.txt
COUNTING ONLY LINES
Like mos UNIX commands, the wc command offers options that instruc the wc to run in different ways, you can tell wc to limit the count just lines, words or characters or any combination of each.
did this short tutorial helped you?
Fri Apr 27, 2012
Thanks for this quick info. Life saver for a custom ruby code relying on Unix shell to paginate.
Wed Feb 29, 2012
--------------- text file. Click on Edit>Go To. Give a huge number than expected number of lines. say if you expect to have 2000 lines, give 5000 or just give 200000. It gives an eror "The Line number is beyond the total number of lines" and shows up the the immediately available line. If you have 2379 lines it gives 2380. So whatever it shows up minus 1 is the actual number of lines in the text file. Cheers!!
Wed Feb 08, 2012
Thank you. Is really helpme
Thu Jan 19, 2012
The easy way to get rid of the filename:
$wc -l < file.txt
Thu Dec 15, 2011
Some one said they don't see as difficult. Selfish. There was a day you knew nothing about this. Thanks to the Author of this tutorial. I am Java developer, using linux all the time, and I rely these kind of tutorials for quick answer. thanks again
Tue Dec 13, 2011
Thanks a lot. Very helpful.
Tue Nov 29, 2011
What about using wc -l with grep where you want to count the number of lines that start with a specific pattern...?
Mon Oct 31, 2011
LOVEIN AWESOME MAN!
Thu Oct 20, 2011
Thanks! Very useful!!!
Tue Sep 20, 2011
you can get rid of the file name also using cut:
wc -l myfile |cut -d' ' -f1
Wed Sep 07, 2011
form me It's very nice to find very fast, how I can count the numbers of lines in file from linux. Thank you very much!
Fri Jul 01, 2011
I'm actually not seeing this as difficult..
Fri Apr 29, 2011
you can also use grep...
grep -c "" file
Fri Apr 29, 2011
Another cool way to do this without the filename and without having to use awk is to do : cat filename.txt | wc -l
Tue Aug 14, 2012
Yes, this is really cool!
Mon Apr 25, 2011
thanks aus! this should really be an OPTION OF wc rather than having to fiddle around the problem.
you saved people's days
Title: How To Count The Number Of Lines In A File In Linux Shell Command
Description: How To Count The Number Of Lines In A File In Linux Shell Command
Tags: how to count the number of lines in a file in linux shell command
Info: This Post Has Been Viewed 0 Times Since
Date: Sun Feb 25, 2007
Author tomas Received 52 Replies #2890
Add Your Website
To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums