Insert 6 digits into a chart

Nee help in :
1.  add my 6 figure into my chart
2.  delete  name in a chart
66666  Gustavson        Ian     25      M       250000
88888 Anderson  Jane    Jane    38      F
need to delete the 1st Jane and insert 450000 under 250000.  Please help me the chart should look like this
66666  Gustavson        Ian     25      M       250000
88888  Anderson        Jane    38      F        450000

Please help!!!!!!!!!!
leftridge1Asked:
Who is Participating?
 
ozoCommented:
perl -i -pe 's/Jane\s+(Jane.*)/$1\t450000/' chart
0
 
leftridge1Author Commented:
when i put in the command it came out like this
66666  Gustavson        Ian     25      M       250000
88888 Anderson  Jane  38       F       450000
Is there any way I can add space to line the chart up.  
0
 
XoFCommented:
awk '{ if ($3~/Jane/) {print $1"\t"$2"\t"$4"\t"$5"\t"$6"\t450000" }else {print $0}}' <file>

if input isn't tab-separated, try this one:
awk '{ if ($3~/Jane/) {print $1"\t"$2"\t"$4"\t"$5"\t"$6"\t450000" }else {print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6}}' <file>

bye,

-XoF-
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
ahoffmannCommented:
another variant:
awk '($4=="Jane"){$4=$5;$5=$6;$6="450000";}{printf("%-6s%-16s%-8s%-8s%-8s%s\n",$1,$2,$3,$4,$5,$6);}' chart
0
 
XoFCommented:
btw:
Perhaps one of you has an idea (according to the given awk-suggestions, I guess not...;) ):
I was just wondering, whether awk provides a kind of "shift-operator" for the postional params/matches....
0
 
ahoffmannCommented:
> .. awk .. "shift-operator"
unfortunately no, at least I don't know of any
sometimes your simply can set a positional parameter "empty, like $3=""; but that is gawk/nawk only
otherwise you have to loop
  for(i=start;i<=NF;i++){$(i-1)=$i;}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.