LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 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
Code:
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
Code:
find -name Makefile -exec sed 'some-rubbish' {} \;
sed: -e expression #1, char 14: unterminated `s' command
andy@eccles:~$ echo ${?}
0
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
jhwilliams
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?

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


Reply


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


All times are GMT -5. The time now is 04:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration