in reply to splitting the bus and print
If I understand the OP's question it this enough a oneliner:
perl -nlE "push @res,/\[(\d+):(\d+)\](\w+)/?map{$3.qq([$_])}$2..$1:$_; +END{say for @res}" portbus.txt
# some number is different cat portbus.txt [15:0]abc [3:0]def ghi jkl [3:0]mno [6:0]pqr stu etc perl -nlE "push @res,/\[(\d+):(\d+)\](\w+)/?map{$3.qq([$_])}$2..$1:$_; +END{say for @res}" portbus.txt abc[0] abc[1] abc[2] abc[3] abc[4] abc[5] abc[6] abc[7] abc[8] abc[9] abc[10] abc[11] abc[12] abc[13] abc[14] abc[15] def[0] def[1] def[2] def[3] ghi jkl mno[0] mno[1] mno[2] mno[3] pqr[0] pqr[1] pqr[2] pqr[3] pqr[4] pqr[5] pqr[6] stu etc
L*perl -nlE "say for/\[(\d+):(\d+)\](\w+)/?map{$3.qq([$_])}$2..$1:$_" po +rtbus.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: splitting the bus and print -- oneliner
by perl vams (Initiate) on Apr 26, 2016 at 11:48 UTC | |
by Discipulus (Canon) on Apr 27, 2016 at 07:16 UTC |