I\'m new to awk and sed, and I\'m looking for a way to truncate a line at 80 characters, but I\'m printing several strings in that line using printf. The last two strings are th
Another way to solve this just using Bash (syntax: ${var:0:80}
), e.g.:
printf "%5d %3s%.2s %4s %s %s \n" "$f" "$month" "$day" "$year" "$from" "${subject::80}"
This truncates the string before it gets to printf
. This method would also allow you to specify different maximum widths for each printed column individually.