Try this script:
Code:
printf "a\tb \tc \td \te\n"; printf "a\tb\tc\td\te\n"
the output in terminal is:
Code:
a b c d e
a b c d e
but the number of characters is different.
How to convert the tab characters in the piped input to spaces, so the result looks the same?
I'm thinking of awk:
Code:
( printf "a\tb \tc \td \te\n"; printf "a\tb\tc\td\te\n" ) | awk '{
s="";
col=0;
for (i=1; i<=length;i++) {
c=substr($0,i,1);
#print "col:", col, "\"" c "\""
if (c == "\t") {
j = 8 - (col % 8);
#print "remainder:", j;
s = s substr(" ", 1, j );
col += j;
} else {
col++;
s = s c;
}
}
print s;
}'