0%

sed-and-awk-without-regex

grep

grep -F 
-F, --fixed-strings
    Interpret PATTERN as a list of fixed strings (instead of regular expressions), separated by newlines, any of which is to be matched.

sed

sed cannot run without regex

sed -i ‘sshttp://127.0.0.1:8080/webinterfaceshttp://192.168.50.13:9091/my/web/interfacesg’ /home/bigbrus_corner/test_sed
         ^                                  ^                                          ^

use s as a separator

awk

use awk and the string functions index() and substr() that don’t use patterns

使用awk内置函数gsed

awk '{gsub("foo", "foofoofoo", $0); print}' data.txt 
awk '{gsub("^USER=.*", "1234*()_+123<>?123", $0); print}' data.txt 
awk -v find="$param1" -v repl="$param2" '{
    while (i=index($0,find)) 
        $0 = substr($0,1,i-1) repl substr($0,i+length(find))
    print
}' file
awk '{gsub(/xxx/,"XXX");print > "test.txt"}' test.txt

awk '...' urfile > tmp
mv tmp urfile

第一种方式有风险:缓冲区溢出