Search code examples
linuxbashawkgawknawk

AWK: Is there a way to limit the width of an output field?


I need to limit the final size of a field to 2048. I could probably use:

ACTION_PARAMETER=substr($2,1,2048);

But is there a better way?


Solution

  • You could use printf

    printf "%.2048s\n", $2