View Full Version : [SOLVED] How do I Sed the output of Find?
October 16th, 2011, 09:42 PM
I wanted to filter the output of Find containing lines such as:
find: ‘/proc/4689/fd’: Permission denied
find / -name xli* -print | sed -n '/denied/d; p'
but I still get all the "Permission denied" lines.
What am I doing wrong?
October 16th, 2011, 10:07 PM
find / -name xli* 2>&1 | sed -n '/denied/d; p'
these are messages sent to stderr, while pipe catches stdout. This construct channels error messages to stdout
alternatively grep instead of sed
find / 2>&1 | grep -v denied
even better to redirect stderr to /dev/null with no piping at all
find / -name xli* 2>/dev/null
October 16th, 2011, 10:54 PM
Besides Vaphell's good advices, I just wanted to point out that the name expression will be affected by shell globbing. My guess is that you don't want that, and you are looking for files and directories that match the intact expression.
In order to do that use:
'xli*' or this
October 17th, 2011, 10:45 AM
Thank you Vaphell and Papibe for your help.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.