unix - gawk/sed: find a line and replace the 3rd column -



unix - gawk/sed: find a line and replace the 3rd column -

i have file:

rs4648841 chr1 2365885 -- t 0.40095 0.228978043022122 chr1:2523811 rs4648843 chr1 2366316 -- t c 0.15694 0.5736208829426915 chr1:2523811 rs61763906 chr1 2366517 -- g 0.07726 0.5566728930776897 chr1:2523811

i need find "rs4648843" in first column , 1 time found line containing want edit 4th column in line "ads" (using sed, gawk doesn't matter)

tried: (but of course of study did not work)

sed '/rs4648843/p' input | sed 's//add/g'

edit: need no new file created, want edit file have already.

try this:

awk '/^rs4648843/ {$4="ads"}1' file | column -t

output:

rs4648841 chr1 2365885 -- t 0.40095 0.228978043022122 chr1:2523811 rs4648843 chr1 2366316 ads t c 0.15694 0.5736208829426915 chr1:2523811 rs61763906 chr1 2366517 -- g 0.07726 0.5566728930776897 chr1:2523811

unix sed gawk

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -