-   Linux - Newbie (
-   -   Terminated by signal 13 (

bellsal 01-05-2011 11:16 PM

Terminated by signal 13
Happy New Year Everyone!

I wrote a single line to search for any file that was modified/created on a certain date. To be cleared, as soon as it finds one file (any file) quit searching; here is the line:

find . -exec stat -c "%y %n" '{}' \; | cut --delimiter=' ' -f1,4 | grep -m 1 2011-01-01

I get what I want, but as soon as it finds the first one it quits and it spits out many many lines of "find: `stat' terminated by signal 13".

What is wrong with my one-line command? And, can anyone help me correct this line so I only get one line output without the "find: `stat' terminated by signal 13"?

Thank you in advance.


crts 01-06-2011 10:18 AM

broken pipe

since you tell grep to quit after its first match the pipe is also closed. And that is exactly what signal 13 means:
Broken pipe: write to pipe with no readers

Here is a working example how to find all files that were modified on 1/Jan/2011

find /path/to/search -newermt 2011-01-01 \! -newermt 2011-01-01  -printf '%Td-%Tm-%TY %p\n' -quit
man find

for more options on the output format.

PS: I am not sure, if the '!' has to be escaped as I did in my example. On my bash it works with an escaped '\!' as well as unescaped '!'.

bellsal 01-06-2011 11:10 AM

Thanks CRTS,

One last question, I don't have "-newermt" as an option to the "find" command. Are you using a different version of "find"? My version is "GNU find version 4.1.20".


crts 01-06-2011 11:37 AM


I just looked into the manpage. The -newerXY feature was first implemented in version 4.3.3.
Can you upgrade your 'find'? If not we'll have to look for a workaround.

crts 01-06-2011 11:48 AM

One more question, if upgrading is not an option:
Does your 'find' have the -newer option implemented? If yes, then here is a possible workaround:

touch -m -d "2011-01-01" dummy1.tmp
touch -m -d "2011-01-02" dummy2.tmp
find /path/to/search -newer "dummy1.tmp" \! -newer "dummy2.tmp"  -printf '%Td-%Tm-%TY %p\n' -quit
rm -f dummy{1,2}.tmp

crts 01-06-2011 02:36 PM


been reading the man-page. As it appears the '-quit' option is also not implemented in your version. However, I discovered that find does not spit out an error message when it encounters a broken pipe but simply quits. So the following is probably a good option for you:

find ../ -printf '%Td-%Tm-%TY %p\n' | grep -m 1 '^01-01-2011'

bellsal 01-06-2011 11:19 PM


You have been a great help. Your last suggestion is the one that works for me.



All times are GMT -5. The time now is 10:13 PM.