Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I exclude the output of lsof -c <processname> /path/ from a list of files in /path/ for example find /path/ -type f

I was thinking something like this:

find /home/ncr/downloads -type f | egrep "lsof -c rtorrent /home/ncr/downloads"

(replace quotes with backticks) but that doesn't seem to work...

I'd actually like to know this for other purposes as well. What is the best way to do this?

share|improve this question

1 Answer 1

you could try somethign like this:

#! /bin/ksh

find /var/log/httpd -type f | while read line
do
    a=`lsof $line`

    if [[ $a == "" ]] ; then
            echo $line "not being used"
    else
            echo $line "being used"
    fi
done
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.