I’ve a file and I want to make the following changes in it:
Replace n consecutive spaces by n-1 spaces.
Example:
Input:
a b c e
fg j ij k
Output:
ab c e
fgj ijk
How do I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do it in
sedas:The regex used
/ ( *)/searches for a space followed by zero or more spaces. It remembers the zero or more spaces part and replaces the entire spaces by the remembered part.