ShellLearning Linux Commands149As (Web design templates) each screen pauses, I press
Tuesday, April 24th, 2007ShellLearning Linux Commands149As each screen pauses, I press the spacebar to go to the next page. Many more Linux commands work on files mostly on text files, but somecommands also work on any file. I describe a few of the file-processingtoolsnext. Counting words and lines in a text fileI am always curious about the size of files. For text files, the number of charac- ters is basically the size of the file in bytes (because each character takes up abyte of storage space). What about words and the number of lines, though? The Linux wccommand comes to the rescue. The wccommand displays thetotal number of characters, words, and lines in a text file. For example, trythe following command: wc /etc/inittab53 229 1666 /etc/inittab The second line shows the output. In this case, wcreports that 53 lines, 229words, and 1666 characters are in the /etc/inittabfile. If you simply wantto see the number of lines in a file, use the -loption, such as this: wc l /etc/inittab53 /etc/inittabAs you can see, in this case, wcsimply displays the line count. If you don t specify a filename, the wccommand expects input from the stan- dard input. You can use the pipe feature of the shell to feed the output ofanother command to wc,which can be handy sometimes. Suppose you want a rough count of the processes running on your system. You can get a list of all processes with the ps axcommand, but instead ofcounting lines manually, just pipe the output of psto wcand you get a roughcount automatically: ps ax | wc -l76Here the pscommand produced 76 lines of output. Because the first linesimply shows the headings for the tabular columns, you can estimate thatabout 75 processes are running on your system. (Of course, this count prob- ably includes the processes used to run the psand wccommands as well, but who s reallycounting?)
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services