In sed, and other tools such as grep and awk, [] is a character class - a character that can match anything inside the brackets. This can be a list, a range, or a combination of the two. If the first character after the left bracket is a carat (^) you invert the class, so the above matches anything except the comma. The asterisk is a special character that tells sed to match the previous character zero or more times. So [^,]* could match anything up to and not including a comma, or anything after a comma.
delete
Change comma to space
Delete all strings in the line that don't include the comma and end in ": ";
Change all commas to spaces.
You're looking at too small a part of the command. A sed substitute command is usually seen in the form:
s/BasicRegularExpression/ReplacementString/flags
There are two sed substitute commands in this case separated by the semicolon ( ; ).
In the first sed substitute command, the Basic Regular Expression is [^,]*: which matches a string of adjacent characters that are not a comma ( [^,] ) appearing zero or more times ( * ) followed by a colon ( : ) followed by a single space character. The Replacement String in this case is the empty string (which effectively removes the matched string). And the flags in this case is g which requests that the substitution be applied globally to all non-overlapping strings that match the BRE.
In the second sed substitute command, the BRE is , which matches a comma character, the replacement string is a space character, and, again, the g flag requests that each comma found on the line be replaced by a space.
One can do that, but if you do the output from the input line:
BUC2 : 1203100,BUC2 COUNT : 318678,BUC2 GIVEN : 3493491.59
becomes:
12031003186783493491.59
instead of:
1203100 318678 3493491.59
One could also get rid of the space after the colon in the BRE:
sed 's/,\{0,1\}[^,]*://g' file
and that would make the output from the above input line be:
1203100 318678 3493491.59
which is almost what is wanted, but has an extraneous leading space on every output line.
One could also try:
sed 's/[^,]*: \([0-9.]*\),\{0,1\}/\1 /g' file
and that looks like the desired output to the naked eye, but has an extraneous trailing space on every output line.
The following seems to do what is wanted with a single sed substitution command:
sed 's/[^,]*: \([0-9.]*\),\{0,1\}[^ ]*\( \{0,1\}\)/\1\2/g' file
but it is not something that I would suggest for someone who is just learning how to use sed and learning how to write sed BREs (unless I was trying to show an example of the sed -specific extensions to standard BREs and the use of back references in replacement strings).
Note that all of the examples above work with standards-conforming versions of sed , but might need an added option on the command line to make it work with GNU sed . For example, the last example above, when using GNU sed , probably needs to be invoked with:
sed --posix 's/[^,]*: \([0-9.]*\),\{0,1\}[^ ]*\( \{0,1\}\)/\1\2/g' file