Second file is like this in 5 columns where firs column contain sometime entries of first file with space and other entries
F2 XYZ CDT CAD it is part of agriculture it is part of university it is part of ... it is used for....
KGM HTC CSP it is part of agriculture it is part of university it is part of ... it is used for....
If there is a match then I have to separate like this in 5 columns
F2 it is part of agriculture it is part of university it is part of ... it is used for....
CAD it is part of agriculture it is part of university it is part of ... it is used for....
KGM it is part of agriculture it is part of university it is part of ... it is used for....
HTC it is part of agriculture it is part of university it is part of ... it is used for....
CSP it is part of agriculture it is part of university it is part of ... it is used for....
Its seemd good code but its not working completely as my output is like this if F2 matches or HTc matches
F2 XYZ CDT CAD it is part of agriculture it is part of university it is part of ... it is used for....
KGM HTC CSP it is part of agriculture it is part of university it is part of ... it is used for...
But I want to remove other non matched entries of first column so that output wilbe
F2 it is part of agriculture it is part of university it is part of ... it is used for....
CAD it is part of agriculture it is part of university it is part of ... it is used for....
KGM it is part of agriculture it is part of university it is part of ... it is used for....
HTC it is part of agriculture it is part of university it is part of ... it is used for....
CSP it is part of agriculture it is part of university it is part of ... it is used for....
Means there should be only matched entry in the first columnin the output.
but yeah, in the input second file there are more than 5 columns therefore, what I wanted is just write whatever is front of common match is present as it is and for sure in columns as input!
And, I checked in the previous output file there are not at all any columns rather entries of 5 columns are row wise..
and regarding tab seaparation entries are like this here each colur represent each column so in input file there are 8 columns.
so if FCGR2A is present in first file then output will be
$ cat file2
F2 XYZ CDT CAD it is part of agriculture it is part of university it is part of ... it is used for....
KGM HTC CSP it is part of agriculture it is part of university it is part of ... it is used for....
$ awk 'NR==FNR{X[$1]=$0;next}{n=split($1,P," ");sub($1,"",$0);for(i=1;i<=n;i++){if(X[P]){print P,$0}}}' file1 FS=" +" file2
F2 it is part of agriculture it is part of university it is part of ... it is used for....
CAD it is part of agriculture it is part of university it is part of ... it is used for....
KGM it is part of agriculture it is part of university it is part of ... it is used for....
HTC it is part of agriculture it is part of university it is part of ... it is used for....
CSP it is part of agriculture it is part of university it is part of ... it is used for....
Finally I am attaching both BD(first) 1diseasedrug(second) files and output file(see)
Pleas check it
these are just part as the files are big and I also got one error
bash-3.2$ awk 'NR==FNR{X[$1]=$0;next}{n=split($1,P," ");sub($1,"",$0);for(i=1;i<=n;i++){if(X[P]){print P,$0}}}' BD FS=" +" diseasedrugbank >see
awk: (FILENAME=diseasedrugbank FNR=471) fatal: Unmatched ( or \(: /DRD2 ADRA1A Droperidol DHBP DRD2 ADRA1A The exact mechanism of action is unknown, however, droperidol causes a CNS depression at subcortical levels of the brain, midbrain, and brainstem reticular formation. It may antagonize the actions of glutamic acid within the extrapyramidal system. It may also inhibit cathecolamine receptors and the reuptake of neurotransmiters and has strong central antidopaminergic action and weak central anticholinergic action. It can also produce ganglionic blockade and reduced affective response. The main actions seem to stem from its potent Dopamine(2) receptor antagonism with minor antagonistic effects on alpha-1 adrenergic receptors as well. A butyrophenone with general properties similar to those of haloperidol. It is used in conjunction with an opioid analgesic such as fentanyl to maintain the patient in a calm state of neuroleptanalgesia with indifference to surroundings but still able to cooperate with the surgeon. It is also used as a premedicant, as an antiemetic, and for the control of agitation in acute psychoses. (From Martindale, The Extra/
bash-3.2$