How do I convert tabs to exact number of spaces in bash script? -
i need convert string tabs string spaces.
but need number of spaces match tabbing format identical.
i need because gnuplot labels don't tabs.
so want:
a fat cat
which a\tvery\tfat\tcat
, converted to:
a fat cat
with spaces, , not to
a fat cat
edit 1
i think misunderstood problem:
$ cat -t aggregate/summary.txt | head -n1 date pnl annpnl days avtrds avevol avedur tdays pnl/$ avpnl stddev maxd shrpe
but when assign variable spaces lost:
$ ff=`cat aggregate/summary.txt | head -n1`; echo $ff date pnl annpnl days avtrds avevol avedur tdays pnl/$ avpnl stddev maxd shrpe
you can use expand
command:
~$ cat >c fast cat nrstaui e ~$ expand c>d
when using cat -a
, can see spaces used (tabs represented ^i
):
~$ cat -a c a^ifast^icat^inrstaui^ie$ ~$ cat -a d fast cat nrstaui e$
edit: if assign line variable, have use double quotes see differences:
~$ f=$(cat c) ~$ echo "$f" |cat -a a^ifast^icat^inrstaui^ie$ ~$ echo $f |cat -a fast cat nrstaui e$
same problem spaces:
~$ f=$(cat d) ~$ echo "$f" |cat -a fast cat nrstaui e$ ~$ echo $f |cat -a fast cat nrstaui e$
Comments
Post a Comment