Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

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

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

share|improve this question

3 Answers 3

up vote 4 down vote accepted

You can do like this:

awk '$35=$35"$"'
share|improve this answer

There are probably more efficient ways to do this. With that caveat:

awk '{$35 = $35"$"; print}' infile > outfile
share|improve this answer

If the field delimiter is <space>:

sed 's/  */$&/35'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.