Tuesday, May 15, 2007

Commenting Multiple lines in a shell script

By using anonymous here document, we can comment multiple lines in a shell script for debugging purposes.

eg:

: << COMMENT
echo "Not in the Scope of debugging/execution"
a=5
b=3
let c=a+b
echo $c
COMMENT

The statements in between the anonymous here document will not be executed.

Tuesday, May 8, 2007

Length of a string in Linux

The command syntax is ${#string}

Example:
linuxdemon$lindem="linux demon"
linuxdemon$echo ${#lindem}
11

Explanation:
1.Assigning the string linux demon to the variable lindem.
2.Determining and printing the length of the string.