LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-05-2011, 10:16 PM   #1
bellsal
Member
 
Registered: Aug 2007
Posts: 42

Rep: Reputation: 0
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
 
Old 01-06-2011, 09:18 AM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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 '!'.

Last edited by crts; 01-06-2011 at 09:21 AM.
 
Old 01-06-2011, 10:10 AM   #3
bellsal
Member
 
Registered: Aug 2007
Posts: 42

Original Poster
Rep: Reputation: 0
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
 
Old 01-06-2011, 10:37 AM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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.
 
Old 01-06-2011, 10:48 AM   #5
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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

Last edited by crts; 01-06-2011 at 01:21 PM. Reason: forgot an option
 
Old 01-06-2011, 01:36 PM   #6
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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'

Last edited by crts; 01-06-2011 at 01:37 PM. Reason: typo
 
Old 01-06-2011, 10:19 PM   #7
bellsal
Member
 
Registered: Aug 2007
Posts: 42

Original Poster
Rep: Reputation: 0
CRTS,

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

Thanks,

bellsal
 
  


Reply

Tags
date, exec, file, find, search



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ld terminated by signal 9 [killed] rustyz82 Linux - Software 3 09-15-2015 08:14 AM
Program terminated with signal SIGFPE, Arithmetic exception shichangyou2 Linux - Newbie 1 05-21-2010 08:57 PM
How to reinstall a signal handler after exec ( Strange behaviour in signal handling ) lali.p Programming 0 09-20-2008 12:11 PM
pptpconfig: pppd process terminated by signal 11 (failed) centos-new Linux - General 1 09-19-2006 11:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration