Search code examples
cssbashsedcss-variables

Shell script for replacing :*; with a comma


I have some css color variables that look this:

--state-success-text:        #3c763d;
--state-success-background:  #dff0d8;

I want to replace the hex color code with a comma. So in other words I want a comma separated list of just the color variables that looks like this:

state-success-text, state-success-background, ...

Thoughts on how to code a bash script that does this?


Solution

  • You are almost there,

    sed 's/--\(.*\):.*;/\1, /'
    

    Should do it. When you do :*;, the column will be expanded several time, adding a . will mean any character.

    EDIT: Modified to also remove the --.