Issue
I have this data set ( txt). For example:
input:
0 275,276,45,278
1 442,22,455,0,456,457,458
75 62,263,264,265,266,267
80 0,516,294,517,518,519
output:
0 275
0 276
0 45
...
1 442
1 22
...
80 0
I use unix terminal. Let me know if you have some ideas. Thanks
Solution
Ignoring the last part you mentioned "80 454", I found a solution to print as required.
Suppose all these values are stored in a file names "stack.txt", the following bash code will be useful.
#!/bin/bash
while read i;do
f=$(awk -F" " '{print $1}' <<< $i)
line=$(cut -d" " -f2 <<<$i)
for m in $(echo $line | sed "s/,/ /g"); do
echo $f" "$m
done
echo "..."
done<stack.txt
Output will be
0 275
0 276
0 277
0 278
0 279
0 280
0 281
0 282
0 283
...
1 442
1 22
1 455
1 0
1 456
1 457
1 458
...
75 62
75 263
75 264
75 265
75 266
75 267
...
80 0
80 516
80 294
80 517
80 518
80 519
...
Answered By - Gautham Sreenivasan Answer Checked By - Katrina (WPSolving Volunteer)