user2456216
user2456216

Reputation: 142

replace a character into awk

I use ${var//string1/string2} for replace characters or strings, now I need do the same but in a specific column awk.

try this for replace space per '_' but does not work

cat file | awk -F',' '{print ${3// /_}'

Upvotes: 2

Views: 1679

Answers (1)

iruvar
iruvar

Reputation: 23374

Use gsub

awk -F, -v OFS=, '{gsub(" ", "_", $3); print}' file.txt 

Upvotes: 4

Related Questions