Thursday, March 23, 2017

Bash: sed - part VIII

Transforming characters

[address]y/inchars/outchars/


The transform command performs a one-to-one mapping of the inchars and the outchars values.


# cat data8.txt


This is line number 1.
This is line number 2.
This is line number 3.
This is line number 4.
This is line number 1 again.
This is yet another line.
This is the last line in the file.





# sed 'y/123/789/' data8.txt


This is line number 7.
This is line number 8.
This is line number 9.
This is line number 4.
This is line number 7 again.
This is yet another line.
This is the last line in the file.




-----------------------------------------

# echo "This 1 is a test of 1 try." | sed 'y/123/456/'

This 4 is a test of 4 try.

No comments:

Post a Comment