> I have a file containing lines like this:
> include/SessionDefs.h, 1.118,,,
> src/screens/apply_joint.trn, 1.7,
> src/screens/custapp_appn_review.obj, 1.30,,,,,,,
> I would like to get rid of all the trailing commas after the number.
> Otherwise,the tabs etc all can stay. Please notr that I have to keep
> the comma after the text.
> Is there a sed command that would do this? any advice is appreciated.
The way to think about this is this: you need to match a digit followed by
any number of commas, and replace with the original matching digit.
To match the pattern you need is '[0-9],*'
To use the matched digit in the replacement, you need to mark it,
like this: '\([0-9]\),*'. Then you can use '\1' in the replacement
to get back the digit which matched.
Putting this together, your sed command should be:
sed -e 's/\([0-9]\),*/\1/'
If the pattern you want to replace may occur more than once per line,
then you need the 'g' suffix:
sed -e 's/\([0-9]\),*/\1/g'