perl one-liner to change : to / and / to : in single line

71 Views Asked by At

Is there a perl one-liner to change ":" to "/" and "/" to ":" in every line of a file.

for example:

fffc002/fffc002:9090 
fffc003/fffc003:9090 
fffc004/fffc004:9090 

above thing should be changed to

fffc002:fffc002/9090
fffc003:fffc003/9090 
fffc004:fffc004/9090 
1

There are 1 best solutions below

0
ikegami On
perl -pe'tr{:/}{/:}'

Specifying file to process to Perl one-liner


That said, you might have a tr command-line utility which could do the same.

tr :/ /: