Artificial intelligent assistant

Bash script to edit text in csv-format As part of an inventory bash script I am checking SFP modules and adding them to a .csv-file. The format currently looks like this, with varying lengths: RO01;1000BaseSX SFP;1000BaseSX SFP RO02;1000BaseSX SFP;1000BaseSX SFP;1000BaseLX SFP My goal is to give each row after the first its own line together with the first row. So the above line should look like this: RO01;1000BaseSX SFP RO01;1000BaseSX SFP RO02;1000BaseSX SFP RO02;1000BaseSX SFP RO02;1000BaseLX SFP How could I achieve this using text processing?

Possible solution could be with using `awk`:


awk -F";" '{ for (i = 2; i <= NF; i++) { printf("%s;%s\
", $1, $i); } }' file


With `awk -F";"` we set `FS`(field separator) to `;`. Then for every row(record) we start from field 2 to the last field (`NF`): `for (i = 2; i <= NF; i++)` and we print field 1 and current field (`$i`).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a9ea6f17adf27e5680d0856c70bb4a21