Hello
Could you help with small script:
How to split string X1 into 3 string
String X1 can have 1 or many strings
X1='A1:B1:C1:D1:A2:B2:C2:D2:A3:B3:C3:D3'
This is output which I want to have:
Z1='A1:B1:C1:D1'
Z2='A2:B2:C2:D2'
Z3='A3:B3:C3:D3'
Hello
Could you help with small script:
How to split string X1 into 3 string
String X1 can have 1 or many strings
X1='A1:B1:C1:D1:A2:B2:C2:D2:A3:B3:C3:D3'
This is output which I want to have:
Z1='A1:B1:C1:D1'
Z2='A2:B2:C2:D2'
Z3='A3:B3:C3:D3'
can you tell more about the string and what to do?
split after every hex value above D1?
split after every table location pointing to 4th column?
One way would be..
[mkt@ michael]$ X1='A1:B1:C1:D1:A2:B2:C2:D2:A3:B3:C3:D3'
[mkt@ michael]$ Z1=$(echo $X1 | cut -d: -f1-4)
[mkt@ michael]$ Z2=$(echo $X1 | cut -d: -f5-8)
[mkt@ michael]$ Z3=$(echo $X1 | cut -d: -f8-)
@daWonderer split after every table location pointing to 4th column.
@michaelrozar17 this will not work if i will have more if i have more strings
Hi,
I think the below script may full fill your requirement.
#! /bin/bash
c=1
info="A1:B1:C1:D1:A2:B2:C2:D2:A3:B3:C3:D3:A4:B4:C4:D4:A5:B5:C5:D5"
for i in `echo $info | sed 's/\([A-Z0-9]*\):\([A-Z0-9]*\):\([A-Z0-9]*\):\([A-Z0-9]*\):/\1:\2:\3:\4\n/g'`
do
eval X$c="$i"
let c=$c+1
done
let c=$c-1
for j in `seq 1 $c`;
do
eval echo \$X$j;
done
Cheers,
Ranga:)
it's possible do with awk ?