Hi,
I need to split a string, either using awk or cut or basic unix commands (no programming) , with a multibyte charectar as a delimeter.
Ex:
abcd-efgh-ijkl
split by -efgh- to get two segments abcd & ijkl
Is it possible?
Thanks
A.H.S
Hi,
I need to split a string, either using awk or cut or basic unix commands (no programming) , with a multibyte charectar as a delimeter.
Ex:
abcd-efgh-ijkl
split by -efgh- to get two segments abcd & ijkl
Is it possible?
Thanks
A.H.S
I'd probably do something like the following with awk (this is from an interactive session)
$ echo "abcd-efgh-ijkl" | awk '{
> n = split ( $0, a, "-efgh-" )
> for ( i = 1; i <= n; i++ ) {
> printf( "Element %d is %s\n", i, a[ i ] );
> }
> }'
Element 1 is abcd
Element 2 is ijkl
$
Obviously, change the regex in the split to whatever you need it to be.
Cheers
ZB