Help needed in formatting script files

Hi,

Can anyone tell me how i can convert all tab spaces inside a script to 4 spaces through another script.

Also i need to find if all the quotes are matching and ended properly. Any idea whould be of great help.

Many thanks!

For the first question you can do someting like:

awk -F"\t" '$1=$1' OFS="    " file

For the second question you should post the input file and the desired output.

@Franklin,

Many thanks for the quick reply.
Can you please explain me what the '$1=$1' does??

For the second part,
If i give a script file that has if loops as input, the script which is formatting should be able to move the lines between if and fi by 4 spaces.

i/p:
 
if ($? eq 0 )
sdfasfsaf
asfdsafs
asdfsfd
fi
 
The output should be like
if ($? eq 0 )
   sdfasfsaf
   asfdsafs
   asdfsfd
fi
 

Thanks for your time!

It's an awk idiom to force awk to rebuild $0 with the new OFS.

With the given inputfile you could do something like:

awk '
/fi/{p=0} 
p{$0="    " $0} 
/if/{p=1}
{print}' file

If this is abracadabra to you you should have a read of:

Awk - A Tutorial and Introduction