Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Replacement of the contents of the file

Shulou Source: shulou.com Published: 2022-06-01 04:33:12 10月01日 Update

1. If it's just a string in a file, you can use g/192.168.254.2/s/192.168.254.2/10.2.2.3/g

The explanation is as follows: Gram 192.168.254.2 indicates that the string 192.168.254.2 is searched in full text, and the string found is followed by

Operation. The string will be replaced by the string substitution in 192.168.254.2 and 10.2.2.3, and the last g indicates the whole substitution.

2. Another method is more worth learning. Sed's myfile 192.168.254.2 Citrus 10.2.2.3 Universe GI. Note two points: first, 10.2.2.3 is followed by a slash, and then-I writes the result directly back to myfile.

Tags: Characters strings files full text whole process just slashes methods results learning search interpretation content Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB MySQL Docker Xiaomi