Unable to translate IP addresses using tr
質問
I have a file that has lot of IP addresses. I need to change those IP addresses into some numbers. Below is how a file "data" will look
152.14.12.1
152.14.12.2
152.14.12.3
When I execute cat data | tr -s '152.14.12.1' '9'
, it replaces everything and the output is 9 9 9 9
. How to do this. Any help would be appreciated.
解決
Maybe you prefer to use sed
, to replace a string, and not tr
that is intended for a SET of chars, like:
cat data | sed "s/152.14.12.1/9/g"
gives you:
9
152.14.12.2
152.14.12.3
所属していません StackOverflow