20 May
Posted by: admin in: Linux Tricks
Often it is necessary to work with big files, that cannot be viewed using standard editors. For example, If you have a 4Gb file, I think you won’t open it with any text editor. But what if you need to know how many bytes are in this file, of how many strings it contains? There is a linux command that allows you to do all this stuff faster than you think. Let’s show it: it’s wc. I’ll describe its options here.
So in order to count the number of lines in a file, go to shell and issue the following command: wc -l <filename>. Enter wc -L <filename> to find the longest line of a file. I think other options are clear. If you’re looking for PHP usage of this command, you are welcome to use system() to gain its output and use for your needs. It can be useful for getting random lines from files, and many other things you might need.
Tags: count of strings in a big file, linux command longest string
Leave a reply