How to replace the content of a specific column with awk?

  • Given: there are 40 columns in a record. I want to replace the 35th column so that the 35th column will be replaced with the content of the 35th column and a "$" symbol. What came to mind is something like:

    awk '{print $1" "$2" "...$35"$ "$36...$40}'

    It works but because it is infeasible when the number of column is as large as 10k. I need a better way to do this.

  • cuonglm

    cuonglm Correct answer

    6 years ago

    You can do like this:

    awk '$35=$35"$"'

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM