I have data in a table. And in one column I need to replace some indices (numbers from 1 to 23) to 3-4 digits sample numbers like: 2347,3856 etc.
So the original column looks like:
SF=1,2
SF=12,7
SF=17,4
And the output should be:
SF=2347,3856
SF=8553,9539
...
The problem is: if I do it for one sample (1->2720) it's fine; but then replacing 2 with something will create a mess etc., and I don't see how can I specify that the number should be replaced if only it's a single(two) digit for example? There could be more than 2 numbers in a row.
Sorry if it sounds confusing. I'm a beginner.
Update. Thanks fo mgjk I succeeded partially. But for some reason the new line is created after the first replacement in a row and then the next number is not replaced obviously. So what I get is:
SF=2347
,2
SF=8553
,7
And here is the code:
'sed "s/=${index},/=${sample},/g; s/,${index} /,${sample} /g; s/,${index},/,${sample},/g" samples.txt'
Why does it happen?