SED command Related:
Https://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html
Https://www.cnblogs.com/DragonFire/p/6600121.html
Here we have to do the function is:
Enter a directory "/data/data8"
Transform it to "\/data\/data8" in the shell (this is to be used directly in the SED command behind the shell)
Let's take a look at how the direct use command is implemented:
Echo "/data/data8" |sed ' s/\//\\\//g '
' s/\/\\\//G ': s represents the substitution of G for the end of the line, three marked black magnified "/" is the character that splits the substitution rule and replaces the result, "\" represents the escape character
If you want to pass in a parameter in the Shell's sed command, you should wrap it in double quotes
Some of the differences in the shell, mainly is a few more escape characters, please understand, the shell code is as follows
Temp= 'echo $1|sed ' s/\//\\\\\//g 'echo $temp
Execution Result:
[Email protected] testshell]#/testtext.sh /data/d\/data\/d
Use the SED command in the shell to replace/\/