LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Terminated by signal 13 (http://www.linuxquestions.org/questions/linux-newbie-8/terminated-by-signal-13-a-854501/)

bellsal 01-05-2011 10: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.

Bellsal

crts 01-06-2011 09:18 AM

broken pipe
 
Hi,

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
Code:

find /path/to/search -newermt 2011-01-01 \! -newermt 2011-01-01  -printf '%Td-%Tm-%TY %p\n' -quit
Read
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 10: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".

bellsal

crts 01-06-2011 10:37 AM

Hi,

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 10: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:
Code:

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 01:36 PM

Ok,

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:
Code:

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

bellsal 01-06-2011 10:19 PM

CRTS,

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

Thanks,

bellsal


All times are GMT -5. The time now is 03:14 PM.