You can use BASH string manipulations (you need to exit /
with \/
):
s='6427//6422 6429//6423 6428//6421' echo "${s//\/\//,}" 6427,6422 6429,6423 6428,6421
Similarly, using awk:
awk -F '//' -v OFS=, '{$1=$1}1' <<< "$s" 6427,6422 6429,6423 6428,6421
PS: tr
cannot be used here, since tr
translates each character in the input of another character in the output, and here you are dealing with 2 //
characters.
source share