Web site traffic - Squeezing Out Spaces At this point, several of
Squeezing Out Spaces At this point, several of the lines have multiple spaces separating the words. You need to reduce or squeeze these multiple spaces into single spaces to avoid problems with counting later in this example. To do this, you need to use the -s ( s as in squeeze) option to the tr command. The basic syntax is tr -s ’set1′ When tr encounters multiple consecutive occurrences of a character in set1, it replaces these with only one occurrence of the character. For example, $ echo “feed me” | tr -s ‘e’ produces the output fed me Here the two e’s in feed were reduced to a single e. If you specify more than one character in set1, the replacement is character specific. For example: $ echo “Shell Programming” | tr -s ‘lm’ produces the following output: Shel Programing As you can see the two l’s in Shell were reduced to a single l. Also, the two m’s in Programming were reduced to a single m. Now you can squeeze multiple spaces in the output into single spaces using the command: $ tr ‘!?”:;[]{}(),.tn’ ‘ ‘ < /home/ranga/docs/ch15.doc | tr 'A-Z' 'a-z' | tr -s ' ' The sort Command To get a count of how many times each word is used, you need to sort the file using the sort command. In its simplest form, the sort command sorts each of its input lines. Thus you need to have only one word per line. You can do this changing all the spaces into new lines as follows: $ tr '!?":;[]{}(),.tn' ' ' < /home/ranga/docs/ch15.doc | tr 'A-Z' 'a-z' | tr -s ' ' | tr ' ' 'n' Now you can sort the output, by adding the sort command:
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.