Hello,
If I understand correctly, you want to replace all space occurances to "\space" where space represents the space, ' ', character:
sed -i 's/ /\\ /' <em>file</em>
To clarify:sed — Is the program.
-i — Is a sed option that can edit files in place (makes backup if extension supplied)
s/ / — Finds all occurances of space
\\ / — Replaces the space with '\ '. Without the single quotation marks.
file — Is the input file.
For reference, the s command is the substitution command. The / / statement is to find any occurance of a space. The \\ / statement will replace the space, ' ', found with '\ '.
- Stack Overflow