I need a string which is not known before the runtime and I'll find the shell The problem is that the string will have special characters such as braces, spaces, dots, slashes, and so on (if Shell is bish, if this is the case).
If I know the string then I can escape special characters at a time, but how can I do that for the whole string?
Running through an SD script to prefix each special character can be an idea, I still need an RTM that how such a script should be written. I do not know if there are other, better, options.
I have read If you have a large expression of string, re_format (7) , but it seems that "there is no such thing as the whole next string literally" ... < P> Edit: To avoid false positivity, I should include a new identity in the pattern, such as.
for example 'myunknownstring'
sed is how I will do it.
s_esc = "$ (echo" $ s "| sed 's / [^ - a-za- z0-9 _] / \\ and / g')" #backslash special character Inv_ent = "$ (egrep" ^ item [0-9] + $$ s_esc loc. + $ "Inventory_list)"
Comments
Post a Comment