script to loop all process ids and take pmap

Hi all,

I need a script that will loop around all the current processes and take a pmap -x <process id> and output each pmap to a separate file.

Would anyone have a quick command to do this?

Example:

for PID in `ps -ef| awk '/<someprocessname>/ {print $2}'`; do pmap -x $PID > ${PID}.outfile; done

Do not use /bin/sh for that script:

ps -eo pid | 
  while read; do
    pid="$(($REPLY))"
    pmap > ./pmap_"$pid" -x "$pid" 2>/dev/null ||
      printf 'error printing address space map for pid %d\n' "$pid" >&2
  done