You are not logged in.

#1 2009-04-20 11:11:55

TheGrudge
Member
Registered: 2006-06-15
Posts: 206
Website

Convert spaces => tabs in multiple files

I try to clean up some source code and convert all tabs with spaces (C++).
But I don't want to do this manually for sure.

So I tried to use the expand command like this:

$>   for i in $(find -type f -iname "*.cpp"); do expand -t4 $i > $i; done

This seems to work at the first look, but checking with

git status

and looking into the actual files, they are all empty now. Any idea how to recursively convert tabs to spaces?


digiKam developer - www.digikam.org

Offline

#2 2009-04-20 11:17:26

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Convert spaces => tabs in multiple files

Maybe....

sed -i "s#\t#    #g" *.cpp

Offline

#3 2009-04-20 11:18:27

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Convert spaces => tabs in multiple files

expand -t4 $i > $i.back; mv $i.back $i;

Offline

#4 2009-04-20 11:30:24

TheGrudge
Member
Registered: 2006-06-15
Posts: 206
Website

Re: Convert spaces => tabs in multiple files

Procyon wrote:

expand -t4 $i > $i.back; mv $i.back $i;

Oh man this was too easy :-D It worked, thank you...


digiKam developer - www.digikam.org

Offline

Board footer

Powered by FluxBB