Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-17-2011, 02:41 PM   #1
Andrew Benton
Senior Member
Registered: Aug 2003
Location: Birkenhead/Britain
Distribution: Linux From Scratch
Posts: 2,073

Rep: Reputation: 64
find -exec - capture exit status?

Hello, sometimes when I script I do things like this
find -name Makefile -exec sed 's/something/something-else/' {} \;
Which is fine if the sed makes sense. However, if the sed is broken in some way and gives an error the script continues because the exit status is given by `find' which succeeded. eg
find -name Makefile -exec sed 'some-rubbish' {} \;
sed: -e expression #1, char 14: unterminated `s' command
andy@eccles:~$ echo ${?}
How do I capture the exit status of the sed so I can make the script stop if there's a problem?

Last edited by Andrew Benton; 12-17-2011 at 02:42 PM. Reason: speling
Old 12-18-2011, 07:11 AM   #2
Senior Member
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 210Reputation: 210Reputation: 210
Does this do what you want?

find . -exec sed 'rubbish' {} \; -o -quit;


Thread Tools Search this Thread
Search this Thread:

Advanced 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
[SOLVED] Capture exit status from unix command in C wtruong Programming 2 10-15-2009 08:44 PM
Find exit status problem aliahsan81 Programming 3 04-18-2009 11:22 AM
cannot find -lpcap collect2: ld returned 1 exit status nasim751 Programming 1 02-12-2008 02:57 PM
ld: cannot find -lc collect2: ld returned 1 exit status ArbuZz Linux From Scratch 3 09-27-2005 01:52 AM
lfs5.1.1 cannot find -lc collect2,returning 1 exit status keyur Linux From Scratch 0 08-17-2004 12:41 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:51 AM.

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