expand

From RaySoft

expand writes the contents of each given file, or standard input if none are given or for a file of -, to standard output, with tab characters converted to the appropriate number of spaces.[1]

Documentation

Syntax

expand [PARAMETER ...] [FILE ...]

Parameters

-i, --initial
Only convert initial tabs (those that precede all non-space or non-tab characters) on each line to spaces.
-t TAB1[,TAB2,...], --tabs=TAB1[,TAB2,...]
If only one tab stop is given, set the tabs TAB1 spaces apart (default is 8). Otherwise, set the tabs at columns TAB1, TAB2, ... (numbered from 0), and replace any tabs beyond the last tab stop given with single spaces. Tab stops can be separated by blanks as well as by commas.

Examples

Replace all tabs in Shell scripts
for newFile in *.sh; do
  bckFile="${newFile}.bck"
  mv "${newFile}" "${bckFile}"
  expand --tabs=2 "${bckFile}" >"${newFile}"
done

References