7 td-expand - Generate multiple rows from each one row in a Tabular data stream.
11 td-expand [-f I<FIELD>] [-s I<SEPARATOR>]
15 It goes row-by-row and splits the given I<FIELD> at I<SEPARATOR> chars,
16 creates as many rows on the output as many parts I<FIELD> is split into,
17 fills the I<FIELD> column in each row by one of the parts,
18 and fills all other columns in all resulted rows with the corresponding column's data in the input.
23 | /bin/bash | user1 user2 |
24 | /bin/dash | user3 user4 |
27 td-expand -f USERS -s ' ' | td-alter USER=USERS | td-select +ALL -USERS
40 =item -f, --field I<FIELD>
42 Which field to break up.
43 Default is always the first one.
45 =item -s, --separator I<PATTERN>
47 Regexp pattern to split I<FIELD> at.
54 td-collapse(1) is a kind of inverse to td-expand(1).
59 $OptFieldName = undef;
60 $OptSeparatorRegexp = " ";
62 'f|field=s' => \
$OptFieldName,
63 's|separator=s' => \
$OptSeparatorRegexp,
66 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
67 do '/usr/lib/tool/perl5/tabdata/common.pl' or die "$@";
70 process_header
(scalar <STDIN
>);
71 print join($FS, @Header).$RS;
75 my @row = read_record
(\
*STDIN
);
77 if(not defined $OptFieldName)
79 $OptFieldName = $Header[0];
82 my @parts = split /$OptSeparatorRegexp/, $row[$Header{$OptFieldName}];
87 $row_copy[$Header{$OptFieldName}] = $part;
88 print join($FS, @row_copy) . $RS;