how can block particular space string in shell using printf
command example result is
tom@x.com 10 john@x.com 11 andrew@x.com 12 thomas_sean@x.com 15
how can align result in proper manner command used in coding is
printf $user$i $time
result desired is
tom@x.com 10 john@x.com 11 andrew@x.com 12 thomas_sean@x.com 15
my code below-
echo $h | cut -f$a -d" " `printf "\t${t[$a]}\t\t $hour:$min:$sec\n"`
possible script
while read -r user time printf "%-20s %s\n" "$user" "$time" done <<'eof' tom@x.com 10 john@x.com 11 andrew@x.com 12 thomas_sean@x.com 15 eof
sample output:
tom@x.com 10 john@x.com 11 andrew@x.com 12 thomas_sean@x.com 15
the %-20s
can adjusted little (%-17s
or %-18s
) if desired, basic idea reserve appropriate number of spaces , left justify string, followed blank , 'time'. \n
newline necessary; printf
not add newline unless request so.