Archive for August, 2007

Sams Teach Yourself Shell Programming (Web site hosting) in 24 Hours

Friday, August 31st, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 16: Filtering Text Using Regular Expressions Previous Chapter Next Chapter Sections in this Chapter: The Basics of awk and sed Summary Using sed Questions Previous Section Next Section Hour 16 Filtering Text Using Regular Expressions The most powerful text filtering tools in the UNIX environment are a pair of oddly named programs, awk and sed. They let shell programmers easily edit text files and filter the output of other commands using regular expressions. A regular expression is a string that can be used to describe several sequences of characters. sed (which stands for stream editor) was created as an editor exclusively for executing scripts. As its name implies, sed is stream oriented, thus all the input you feed into it passes through and goes to STDOUT. It does not change the input file. In this chapter I will show you how to use sed in shell scripts. I will cover awk programming in Chapter 17, “Filtering Text with awk,” but I’ll discuss some of the many similarities between awk and sed at the beginning of this chapter. The Basics of awk and sed Invocation Syntax Regular Expressions Basic Operation There are many similarities between awk and sed: l They have similar invocation syntax. l They enable you to specify instructions that execute for every line in an input file. l They use regular expressions for matching patterns . For those readers who are not familiar with patterns and regular expressions, I will explain them shortly. Invocation Syntax The invocation syntax for awk and sed is as follows: command ’script’ filenames Here command is either awk or sed, script is a list of commands understood by awk or sed, and filenames is a list of files that the command acts on.
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Shared web hosting - If you are using a Linux or FreeBSD

Thursday, August 30th, 2007

If you are using a Linux or FreeBSD system, you need to sort on column 1. On other systems you need to sort on column 2. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 15: Text Filters Previous Chapter Next Chapter Sections in this Chapter: The head and tail Commands Summary Using grep Questions Counting Words Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Sams Teach Yourself Shell Programming in 24 Hours (Web design careers)

Wednesday, August 29th, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 15: Text Filters Previous Chapter Next Chapter Sections in this Chapter: The head and tail Commands Summary Using grep Questions Counting Words Previous Section Next Section Questions 1. Given the following shell function lspids() { /bin/ps -ef | grep “$1″| grep -v grep ; } make the necessary changes so that when the function is executed as follows $ lspid -h ssh the output looks like this: UID PID PPID C STIME TTY TIME COMMAND root 2121 1 0 Nov 16 ? 0:14 /opt/bin/sshd Also, when the function executes as $ lspid ssh the output looks like this: root 2121 1 0 Nov 16 ? 0:14 /opt/bin/sshd Here you are using ssh as the word specified to grep, but your function should be able to use any word as an argument. Also, validate that you have enough arguments before executing the ps command. If you are using a Linux or FreeBSD-based system, please use the following version of the function lspids as a starting point instead of the version given previously: lspids() { /bin/ps -auwx 2> /dev/null | grep “$1″| grep -v grep ; } (HINT: The header that you are using is the first line in the output from the /bin/ps -ef command.) 2. Take the function you wrote in question 1 and add a -s option that sorts the output of the ps command by process ID. The process IDs, or pids, do not have to be arranged from largest to smallest.
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Professional web hosting - Sams Teach Yourself Shell Programming in 24 Hours

Tuesday, August 28th, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 15: Text Filters Previous Chapter Next Chapter Sections in this Chapter: The head and tail Commands Summary Using grep Questions Counting Words Previous Section Next Section Summary In this chapter you looked at some of the commands that are heavily used for filtering text in scripts. These commands include: l head l tail l grep l sort l uniq l tr I also covered how to combine these commands together to solve problems such as counting the number of times a word was repeated in a text file. In Chapter 16 I will introduce two more text filtering commands, awk and sed, that give you much more control over editing lines and printing specific columns of your output. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 15: Text Filters Previous Chapter Next Chapter Sections in this Chapter: The head and tail Commands Summary Using grep Questions Counting Words Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

tr ‘[:classname:]’ ’set2′ Here classname is the name (Web host server)

Monday, August 27th, 2007

tr ‘[:classname:]’ ’set2′ Here classname is the name of one of the classes given in Table 15.1, and set2 is the set of characters you want the characters in classname to be transliterated to. For example, to get rid of punctuation and spaces, you use the punct and space classes: $ tr ‘[:punct:]’ ‘ ‘ < /home/ranga/docs/ch15.doc | tr '[:space:]' ' ' | tr 'A-Z' 'a-z' | tr -s ' ' | tr ' ' 'n' | sort | uniq -c | sort -rn | head Here's some of the new output: 405 the 170 to 136 a 134 of 122 and 119 is 80 files 74 file 72 in 67 or The numbers are different for some of the words because I ran the commands and wrote the chapter at the same time. I could also have replaced 'A-Z' and 'a-z' with the upper and lower classes, but there is no real advantage to using the classes. In most cases the ranges are much more illustrative of your intentions. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 15: Text Filters Previous Chapter Next Chapter Sections in this Chapter: The head and tail Commands Summary Using grep Questions Counting Words Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Web and email hosting - tr ‘A-Z’ ‘a-z’ | tr -s ‘ ‘

Sunday, August 26th, 2007

tr ‘A-Z’ ‘a-z’ | tr -s ‘ ‘ | tr ‘ ‘ ‘n’ | sort | uniq -c | sort -rn | head 389 the 164 to 127 of 115 is 115 and 111 a 80 files 70 file 69 in 65 ‘ You might have noticed that the tenth most common word in this chapter is the single quote character. You might be wondering what’s going on because I said you took care of the punctuation with the very first tr command. Well, I lied (sort of). You took care of all the characters that would fit between quotes, and a single quote won’t fit. So why not backslash escape that sucker? Well, not all versions of the shell handle that properly. So what’s the solution? The solution is to use the predefined character sets in tr. The tr command knows several character classes, and the punctuation class is one of them. Table 15.1 gives a complete list of the character class names. TABLE 15.1 CHARACTER CLASSES UNDERSTOOD BY THE TR COMMAND Class Description alnum Letters and digits alpha Letters blank Horizontal whitespace cntrl Control characters digit Digits graph Printable characters, not including spaces lower Lowercase letters print Printable characters, including spaces punct Punctuation space Horizontal or vertical whitespace upper Uppercase letters xdigit Hexadecimal digits The way to invoke tr with one of these character classes is
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

in 69 ‘ 65 (Florida web design) the 389 to 164

Saturday, August 25th, 2007

in 69 ‘ 65 the 389 to 164 of 127 Now you need to tell sort to sort on the second column, and you cannot simply use the -r and -n options. You need to use the -k ( k as in key) option also. The sort command constructs a key for each line in the file, and then it arranges these keys into sorted order. By default, the key spans the entire line. The -k option gives you the flexibility of telling sort where the key should begin and where it should end, in terms of columns. The number of columns in a line is the number of individual words on that line. For example, the following line contains three columns: files 80 100 The basic syntax of the -k option is sort -k start,end files Here start is the starting column for the key, and end is the ending column for the key. The first column is 1, the second column is 2, and so on. For the switched.txt file, start and end are both 2 because there are only two columns and you want to sort on the second one. The command you use is $ sort -rn -k 2,2 switched.txt the 389 to 164 of 127 is 115 and 115 a 111 files 80 file 70 in 69 ‘ 65 Because there are only two columns, you can omit the ending column as follows: $ sort -rn -k 2 switched.txt Using Character Classes with tr Take a look at the output of the command: $ tr ‘!?”:;[]{}(),.tn’ ‘ ‘ < /home/ranga/docs/ch15.doc |
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Web server application - but also the number of times a word

Saturday, August 25th, 2007

but also the number of times a word occurs. You can do this by specifying the -c ( c as in count) option to the uniq command: $ tr ‘!?”:;[]{}(),.tn’ ‘ ‘ < /home/ranga/docs/ch15.doc | tr 'A-Z' 'a-z' | tr -s ' ' | tr ' ' 'n' | sort | uniq -c Sorting Numbers At this point the output is sorted alphabetically. Although this output is useful, it is much easier to determine the most frequently used words if the list is sorted by the number of times a word occurs. To obtain such a list, you need sort to sort by numeric value instead of string comparison. It would also be nice if the largest number was printed first. By default, sort prints the largest number last. To satisfy both of these requirements, you specify the -n ( n as in numeric) and -r ( r as in reverse) options to the sort command: $ tr '!?":;[]{}(),.tn' ' ' < /home/ranga/docs/ch15.doc | tr 'A-Z' 'a-z' | tr -s ' ' | tr ' ' 'n' | sort | uniq -c | sort -rn By piping the output to head, you can get an idea of what the ten most repeated words are: $ tr '!?":;[]{}(),.tn' ' ' < /home/ranga/docs/ch15.doc | tr 'A-Z' 'a-z' | tr -s ' ' | tr ' ' 'n' | sort | uniq -c | sort -rn | head 389 the 164 to 127 of 115 is 115 and 111 a 80 files 70 file 69 in 65 ' Sorting Numbers in a Different Column In the preceding output, you used the sort -rn command to sort the output by numbers because the numbers occurred in the first column instead of the second column. If the numbers occurred in any other column, this would not be possible. Suppose the output looked like the following: $ cat switched.txt files 80 file 70 is 115 and 115 a 111
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Web design course - $ tr ‘!?”:;[]{}(),.tn’ ‘ ‘ < /home/ranga/docs/ch15.doc |

Friday, August 24th, 2007

$ tr ‘!?”:;[]{}(),.tn’ ‘ ‘ < /home/ranga/docs/ch15.doc | tr 'A-Z' 'a-z' | tr -s ' ' | tr ' ' 'n' | sort The uniq Command At this point, you can eliminate all the repeated words by using the -u ( u as in unique) option of the sort command. Because you need a count of the number of times a word is repeated, you should use the uniq command. By default, the uniq command discards all but one of the repeated lines. For example, the commands $ echo ' peach peach peach apple apple orange ' > ./fruits.txt $ uniq fruits.txt produce the output peach apple orange As you can see, uniq discarded all but one of the repeated lines. The uniq command produces a list of the uniq items in a file by comparing consecutive lines. To function properly, its input needs to be a sorted file. For example, if you change fruits.txt as follows $ echo ‘ peach peach orange apple apple peach ‘ > ./fruits.txt $ uniq fruits.txt the output is incorrect for your purposes: peach orange apple peach Returning to the original problem, you need uniq to print not only a list of the unique words in this chapter
We recommend high quality webhost to host and run your jsp application: christian web host services.

Web site traffic - Squeezing Out Spaces At this point, several of

Thursday, August 23rd, 2007

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.