Delete first 2 character from string

Hi ! All,

I have to delete first 2 characters from string. How its possible?
Like string value is "2001". I required output as "01"

Plaese help me.

Nitin

echo $string | sed 's/^..//'

Very Very Thanks.

But I have required that resulted substring ("01"), be store in a variable. So that I can use it in a script.

Nitin

I could give you C code if it helps...

int i;
for (i = 0; i < strlen(string)-1; i++)
(*string+i) = *(string+i+2);

PS To store the output from the above post, just do this:
string = $string | sed 's/^..//'

Try:

substring=`echo $string | sed 's/^..//'`

  • dEvNuL