perl -nle "my (@c) = /\:(\w+)\:/g; print join '.', @c" input> out:caputure1:out:capture2:out output> caputure1.capture2 #### perl -nle "my (@c) = s/\:(\w+)\:/X/g; print join '.', @c" input> out:caputure1:out:capture2:out output> 2