Web servers - #!/bin/sh for i in $@ ; do if

#!/bin/sh for i in $@ ; do if [ -f $i ] ; then echo $i awk ‘ /^ *$/ { x=x+1 ; print x ; }’ $i else echo “ERROR: $i not a file.” >&2 fi done In the awk command, you increment the variable x and print it each time a blank line is encountered. Because a new instance of the awk command runs for each file, the count is unique of each file. Consider the file urls.txt, which contains four blank lines: $ cat urls.txt http://www.cusa.berkeley.edu/~ranga http://www.cisco.com ftp://prep.ai.mit.edu/pub/gnu/ ftp://ftp.redhat.com/ http://www.yahoo.com/index.html ranga@kanchi:/home/ranga/pub ranga@soda:/home/ranga/docs/book/ch01.doc For urls.txt, the output of this script looks like the following: urls.txt 1 2 3 4 There are two important things to keep in mind about numeric expressions: l If either num1 or num2 is the name of a variable whose value is a string rather than a number, awk uses the value 0 rather than the string. l If you use a variable that has not yet been created in a numeric expression, awk creates the variable and assigns it a value of 0. The Assignment Operators In the previous example, the awk command: awk ‘ /^ *$/ { x=x+1 ; print x ; }’ $i Uses the assignment:
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply