* Each line consists of two fields, separated by a pipe '|', where
* the first field is a comma-separated list of items, and
* the second field is a tag.
This is my INPUT:
100,210,354,462|acct
331,746,50|mis
90,263,47,14|sales
and required OUTPUT:
100acct
210acct
354acct
462acct
331mis
746mis
50mis
90sales
263sales
47sales
14sales
This might work for you (GNU sed):
Explanation:
s/\s*//remove whitespace at the front of the record.:a;s/,\(.*|\(.*\)\)/\2\n\1/;tareplace each,by the last field and a newlines/|//remove the|To preserve whitespace use: