How to count the number of lines in a file in linux shell command
How to count the number of lines in a file in linux shell command
Post Description: how to count the number of lines in a file in linux shell command Linux
Post Tags:
This Post Has Been Viewed 9077 Times Since Sun Feb 25, 2007 2:09 pm Author
tomas with 23 replies
Next Post »»
How to get display list of previous commands used in linux shell How to count the number of lines in a file in linux shell command
Advertise On This Page
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?
Links Related to : How to count the number of lines in a file in linux shell command
Comments and replies About How to count the number of lines in a file in linux shell command
::
1 ::
Reply #50738 Reply By
me On Sat Apr 19, 2008 6:32 am
me:
just what i was looking for, thanks!
::
2 ::
Reply #56724 Reply By
himadri On Fri Jun 06, 2008 10:38 am
himadri:
oh yes it certainly did ..thanks a lot mate
::
3 ::
Reply #57246 Reply By
mateen On Tue Jun 10, 2008 4:31 am
mateen:
yes, tutorial is really helpful.
::
4 ::
Reply #60701 Reply By
amit On Mon Jul 07, 2008 10:59 am
amit:
yes, it was very helpful. thanks and looking forward to learn more here.
regards.
::
5 ::
Reply #69570 Reply By
Anas On Sat Sep 06, 2008 3:01 am
Anas:
great! thank you, that helped me!
::
6 ::
Reply #71021 Reply By
Dani On Thu Sep 18, 2008 5:42 am
Dani:
couldnt remember the bloody command name for this, thanks mate.
::
7 ::
Reply #71998 Reply By
tommy On Wed Sep 24, 2008 12:35 pm
tommy:
thanks bro, helped alot!
::
8 ::
Reply #76173 Reply By
Arthur On Sat Oct 18, 2008 11:36 pm
Arthur:
just what i needed thanks.
::
9 ::
Reply #82367 Reply By
anonymous On Thu Nov 20, 2008 7:07 pm
anonymous:
thanks.. was looking for this...
::
10 ::
Reply #85655 Reply By
lobner On Wed Dec 10, 2008 12:52 pm
lobner:
needed just that info... thx
::
11 ::
Reply #96040 Reply By
london On Thu Mar 05, 2009 9:58 am
london:
please show me how to count number of comment lines using shell script
::
12 ::
Reply #97710 Reply By
col On Fri Mar 20, 2009 11:08 am
col:
cat file.txt > grep # > count.txt
wc -l count.txt
::
13 ::
Reply #97711 Reply By
col On Fri Mar 20, 2009 11:09 am
col:
cat file.txt > grep # > count.txt
wc -l count.txt
Dave:
nice! googled it and here it is!
::
15 ::
Reply #104695 Reply By
Shaik On Fri May 29, 2009 8:11 am
Shaik:
very nice...just looking for dis.......
::
16 ::
Reply #107029 Reply By
bass On Mon Jun 22, 2009 10:45 am
bass:
cheers for short and good solution.
that hepled me a lot
::
17 ::
Reply #110712 Reply By
Gavin On Mon Jul 27, 2009 3:30 am
Gavin:
yes it did, short and sweet and exactly what i needed. i am a noob.
::
18 ::
Reply #114415 Reply By
Ankur On Tue Sep 01, 2009 4:29 am
Ankur:
how to add something at the starting of each line using a shell script
::
19 ::
Reply #119605 Reply By
nisha On Wed Nov 04, 2009 7:01 pm
nisha:
thanks it helped me a lot
::
20 ::
Reply #120739 Reply By
linux On Mon Nov 16, 2009 8:47 pm
linux:
i like the way you tell the solution of the problem of line counting.
::
21 ::
Reply #125863 Reply By
James On Thu Jan 14, 2010 1:51 am
James:
Just what I needed - thanks!
matt:
Perfect, exactly what i needed, could expand for other uses.
::
23 ::
Reply #129368 Reply By
randomguy On Fri Mar 05, 2010 3:26 am
randomguy:
well I needed something to count the running processes or the amount of elements in a directory.
But your tutorial reminded me of the WC-command and i set up THIS solution:
ls | wc -l
ps -e | wc -l
etc...
thx