user2217783
user2217783

Reputation: 23

how to replace content of specified column in a huge file using Unix Command

I have a huge file around 10 GB. And I want to replace its 35th column (separated by ;). Since, its a huge file, opening file in an editor is not an option. I want to do replace in all the lines of file.

Somebody suggested me to use Sed but i am not comfortable with it yet. Could somebody suggest a unix command that can achieve the same.

Upvotes: 0

Views: 8940

Answers (3)

yahan
yahan

Reputation: 81

the accepted solution didn't work for me. But helped me in finding this:

awk '{$35 = "replacement"; print $0}' < oldfile > newfile

for a tab separated file

Upvotes: 0

potong
potong

Reputation: 58430

This might work for you (GNU sed):

 sed -i 's/[^;]*/replacement/35' file

Upvotes: 0

Barmar
Barmar

Reputation: 781058

awk -F';' '{ $35 = "replacement" }' < oldfile > newfile

Upvotes: 2

Related Questions