I run SAS codes through bash.
So when I do a ps -u <user-id> ..(1) I get the following:
UID PID TTY TIME CMD 327208 921620 - 0:00 sftp-server 327208 1409136 - 0:00 sshd 327208 1503426 pts/24 0:00 ps 327208 1683576 pts/24 0:00 elssrv 327208 2334914 pts/24 0:00 ksh 327208 2609352 pts/24 0:00 sas 327208 2838702 pts/24 0:04 sas 327208 3490018 pts/24 0:00 elssrv 327208 4436128 - 0:00 sftp-server 327208 4722852 pts/24 369:02 sas 327208 4964572 pts/24 0:00 elssrv 327208 5959866 - 0:01 sshd 327208 5976318 - 0:01 sshd Now, if I do ps -u <user-id>|grep sas ..(2)
I get the sas processes:
327208 2609352 pts/24 0:00 sas 327208 2838702 pts/24 0:05 sas 327208 4722852 pts/24 369:51 sas On the other hand if I do a ls -l /proc/4722852/cwd, ..(3) I get the location where I ran the process with PID 4722852.
Is there a way to connect the command in (2) and (3)?
The output would be the location of all SAS codes that I get by running ps -u <user-id>|grep sas?
ls -l /proc/$(pgrep sss)/cwdand otherwise usels -l /proc/$(pgrep sss | tail -n1)/cwdps -u <userid> | grep sas | awk '{print $2}' | ls -l /proc/$@/cwdpgrepis accessible for normal users as well and not limited to root. If you want it quick and dirtyps -u <user-id> |awk '/sas/{print $1}' | ls -l /proc/$(</dev/stdin)/cwd