how to find a regular expression of specific string

EDIT: As OP mentioned in case any de is empty with respective id then print an hyphen, then try following.

awk '
BEGIN{
  OFS="\t"
  print "ID\t\tDE"
}
/ID/{
  if(id){
    print id,de?de:"-"
    id=de=""
  }
  id=$2
  next
}
/DE/{
  $1=""
  sub(/^ +/,"")
  de=$0
}
END{
  if(id){
    print id,de?de:"-"
  }
}'  Input_file


Could you please try following.

awk '
BEGIN{
  OFS="\t"
  print "ID\t\tDE"
}
/ID/{
  if(id){
    print id,de
    id=de=""
  }
  id=$2
  next
}
/DE/{
  $1=""
  sub(/^ +/,"")
  de=$0
}
END{
  if(id){
    print id,de
  }
}'   Input_file

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)