Tab positioning

xx00102 1(SG): [ . ]   [ @ ]
xx00102 3(SG): [ @ ]   [ . ]
xx00115 lan900:        [ @ ]   [ . ]
xx00115 lan901:        [ . ]   [ @ ]
xx00116 1(SG): [ . ]   [ @ ]
xx00116 3(SG): [ @ ]   [ . ]

the boxes are echoed on the same line with one \t. Is there anyway to get all the boxes to line up? Or possibly is there a way to fix the position of something on the line regardless of what is in front of it. Like this:

xx00102 1(SG): [ . ]   [ @ ]
xx00102 3(SG): [ @ ]   [ . ]
xx00115 lan900:[ @ ]   [ . ]
xx00115 lan901:[ . ]   [ @ ]
xx00116 1(SG): [ . ]   [ @ ]
xx00116 3(SG): [ @ ]   [ . ]

Let me know if this doesnt make any sense and I will try to explain more. Thanks!

Try:

perl -ne '/(.*:)(.*)/;$x=$1;$y=$2;$y=~s/^\s+//;printf "%-15s%s\n",$x,$y' file

Is there a way to do it without perl, possibly using KSH or awk. Thanks for the post though

awk -F":" '{sub("^[ \t]+","",$2);$1=$1":";printf "%-15s%s\n",$1,$2}' file
1 Like