I have huge file, a smallest one is about 9GIG of data that needs to verify how many records in the files after sftp from the client. Currently I use cat <filename> |wc -l to get the job done. I was wondering is there a better of doing it.
At the risk of angering the OOUC police, this is one place where [tt]cat[/tt] adds functionality. The [tt]wc[/tt] command on it's own also displays the file name. If all you need is the count, putting it through a pipe with [tt]cat[/tt] does it nicely.
If you just need the count with no file name after it, this works too...
europe
Whilst I agree that your sed solution provides the correct answer the problem is counting the lines in a file. This is what wc was designed to do. I still see wc as the right tool for the job and Sam's suggestion removes the need for cat which keeps the UUOC police happy.
What's the OOUC-police?
Being a major of the gtlt-police, I have to add:
It is forbidden to decorate your filename in a fancy, personal gt/lt-style like this:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.