remove the specific word from the field

With shown samples could you please try following.

awk '
match($0,/0 ,\(\(/){
  val=substr($0,RSTART,RLENGTH)
  sub(/.*,/,"",val)
  print substr($0,1,RSTART-1) val substr($0,RSTART+RLENGTH)
  val=""
  next
}
1
'  Input_file

Explanation: Adding detailed explanation for above.

awk '                               ##Starting awk program from here.
match($0,/0 ,\(\(/){                ##Using match function to match 0 space (( in line.
  val=substr($0,RSTART,RLENGTH)     ##creating val which has sub string of matched regex.
  sub(/.*,/,"",val)                 ##Substituting everything till comma with NULL in val.
  print substr($0,1,RSTART-1) val substr($0,RSTART+RLENGTH)  ##Printing sub string val and rest of line sub string here.
  val=""                            ##Nullifying val here.
  next                              ##next will skip all statements from here.
}
1                                   ##will print the current line here.
' Input_file                        ##Mentioning Input_file name here.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top