Solved Remove tabs and trailing spaces

May 3, 2012 at 12:08:12
Specs: Windows XP
Indentations to be followed:
1. Tab in the between the code get replace by a single space.
2. Leading tab should replace by 4 spaces.
3. No trailing white spaces.

Please help with the script/command which can correct script as per above mentioned indentation rules.


See More: Remove tabs and trailing spaces

Report •

#1
May 5, 2012 at 09:39:16
Here are some suggestions. Since you haven't mentioned what script you are using, I have given these commands in bash script.

1. To replace tabs in code with a single space
tr '\t' ' '

2. To replace leading tabs with 4 spaces
tr '^\t' ' '


Report •

#2
May 6, 2012 at 16:24:01
✔ Best Answer
This is just a mod of your previous question:

http://www.computing.net/answers/un...

Replace this sed command in the for loop of the other answer. Once again, there is a real TAB character between []:

sed -e 's/[ ]/ /' -e 's/[ ]/ /g' -e 's/[ ]*$//' $file > ./tmp.file



Report •
Related Solutions


Ask Question