I have opened abc.pdf in Document Viewer 3.18.2. I am writing bash script to close the specific document opened in Document Viewer. Any idea ?
displays the a header and the first 9 processes. This helps you identify which column that contains the process ID (PID).
ps -Af|grep evince | grep abc.pdf
displays processes where evince is running files, that contain adc.pdf in the file name. Normally it will be only one such process. And you kill it like you did manually, but with that command in the script.
You can create a variable that contains the PID, and use it for the kill command. In my Lubuntu 16.04.1 LTS system the second column contains the PID. The following two command lines should do the job from a shellscript file.
pid=$(ps -Af|grep evince | grep abc.pdf| tr -s ' ' ' '|cut -d ' ' -f 2) kill $pid
You may have to modify the first of these lines, so that it picks the correct column or 'field' with the option -f at the end. (And you may have to modify the file name, if it is not always abc.pdf.)