Wednesday, December 23, 2009

shell command substring

The below command will print the string which is taken from the 9th index to 4 characters from 9th index.
echo | awk '{ print substr("'"$STRING"'",9,4) }'

Monday, December 21, 2009

Example Find query

The below command will list files on branch_7.0 which are not having the mentioned labels.
ct find . -version "{version(…/bracnch_7.0/LATEST) && ! lbtype(label1) && ! lbtype(label2) && ! lbtype(label3) && ! lbtype(lable4T) && ! lbtype(lable5) && ! lbtype(lable66)} " -print

Wednesday, December 9, 2009

How to create Perl Packages/Modules?

Create a file called cc.pm where the package/module name is cc. Copy the below code. I have created my own print function called myprint and going to call this function from some other script.

[murugaia@build1] ~> cat cc.pm
package cc;
sub myprint
{
my $Element = pop(@_);
print("Hai $Element\n");
};
1;

Create another script which will call package cc and its functions. Here myprint function has been called from package cc.

[murugaia@blrmimsbuild1] ~> cat cc.pl
#! /usr/bin/perl
use cc;
$print=cc::myprint("Sathiyseelan");
print("$print");

[murugaia@build1] ~>
[murugaia@build1] ~>