#!/usr/local/bin/perl use strict; use warnings; open(OF,">outr") || die "File not opening outr: $!\n"; foreach (`ps -ef | grep jones` =~ /[^\n]*\n/g) { next if m!/usr/local/bin/perl ps1$! or /sh -c ps -ef \| grep jones > outr$/; print OF; } close(OF);