Hi All,
Can anybody help me to get the substring from the given string.
In what context ? What shell/tools are you using, and what exactly do you need to achieve?
I want to retain a string except last two characters i.e. if string is "abcdef" , i want "abcd".
It can get as simple as ${string%??}
Look into man ksh for more details.
${name#pattern}, ${name##pattern}
If pattern matches the beginning of the value of parameter name,
the matched text is deleted from the result of substitution. A
single # results in the shortest match, two #?s results in the
longest match.
${name%pattern}, ${name%%pattern}
Like ${..#..} substitution, but it deletes from the end of the
value.
You can also use typedef to get what you want.