Home > Net >  Inherited some sed code and I know it's replacing some characters, but not which ones. 1,$s/ *$
Inherited some sed code and I know it's replacing some characters, but not which ones. 1,$s/ *$

Time:04-22

I know this sed command is replacing some special characters in a file, but I can't figure out what characters. I don't need to learn sed - we're getting off of Unix. I need to know what is being replaced.

$d
1,$s/ *,/,/g   (Is this replacing any number of spaces followed by a comma with just a comma?)
1,$s/ *$//g    (This is the one I can't figure out. What does the dollar sign mean after the asterisk?)
1,$s/, */,/g'  (Is this replacing a comma followed by any number of spaces with just a comma?)

I assure you that googling any piece of that code does not return anything helpful. :)

CodePudding user response:

You got the first and third ones, they're removing spaces before and after a comma.

$ is the end-of-line character, so the second one removes trailing spaces from the end of the line.

  • Related