I am trying to find the latest modified files in my system say in the last 2 hours or so. The command that I am using is:
sudo find / -mmin -120 -printf '%T@ %p\n' | sort -n | cut -f2- -d" " | more
But the above command outputs a lot of entries that contain the string /proc
. So, are there any better ways by which I can remove those lines from the output?
Also, if you have any better methods to deal with the above situation then please suggest. The only criteria is that the output should contain files as well as directories.
EDIT:-
I modified the above command to also include names with newline
, then added Arronical's answer and αғsнιη's answer to it. The final outcome is:
sudo find / ! -path '*/proc*' -type f -mmin -120 -exec ls -al {} \; | grep -v anystring | less
Best Answer
You can use
grep -v
to remove lines containing a string, such as '/proc', you could add this as a pipe to your command to make:However, as files in
/proc/
are transitory in nature, you'll be likely to get some errors likeYou can avoid these by redirecting the STDERR of the find command to
/dev/null
using,2>/dev/null
like so:A Better Method
Rather than filtering the results, and getting rid of your error messages, you can alter your find command so that it never looks in
/proc
: