Contents
What is the command to remove space in Linux?
Use sed ‘s/^ *//g’, to remove the leading white spaces. There is another way to remove whitespaces using `sed` command. The following commands removed the spaces from the variable, $Var by using `sed` command and [[:space:]].
How do you escape the space characters?
You can also add a backslash before whitespace characters such as space, tab, newline and formfeed. However, it is cleaner to use one of the easily readable escape sequences, such as ‘ t ‘ or ‘ s ‘, instead of an actual whitespace character such as a tab or a space.