Sponsored Content
Full Discussion: Exit Status Of Find Command
Top Forums UNIX for Dummies Questions & Answers Exit Status Of Find Command Post 302816109 by Ariean on Monday 3rd of June 2013 10:33:10 AM
Old 06-03-2013
Exit Status Of Find Command

Hello All,
I am trying to capture the exit status of find command and want to delete the files only when it is successful. But it is always returning me as success even if the pattern of that file doesn't exist in the current directory. please help, checked manual page but couldn't able to figure out.

Code:
#!/bin/bash -x
logit()
{
 echo "[${USER}][`date`] - ${*}" >> ${LOG_FILE}
}

LOG_FILE=/home/infrmtca/bin/findtest.log


if  find . -type f -name "*xyz*"
then
        logit "Success"
        find . -type f -name "*xyz*" -delete
else
        logit "Failure"
fi

Code:
[infrmtca][Mon Jun  3 10:18:10 EDT 2013] - Success

Tried this statement as well but it is always 0.
Code:
find . -type f -name "*xyz*" -exec ls {} \;

Thank you.
 

10 More Discussions You Might Find Interesting

1. Programming

How to find the exit status of last command in Unix?

Hi, I want to find the exit status of the last executed command in C Shell. Tried $? but getting the error Variable syntax...$? does not seem to work in C shell.. is there any other command in C shell to find the exit status of last command? Thanks in advance, raju (1 Reply)
Discussion started by: rajugp1
1 Replies

2. UNIX for Dummies Questions & Answers

how to find the exit status for the last executed command

I am executing a find command in my script i.e find $2 -type f -name '*.gif' -mtime +$1 -exec rm {} \; how do i check that this command is executed properly.. i would lke t trap the errror and display my error message kinly help.. this is an urgent issue. (1 Reply)
Discussion started by: vijay.amirthraj
1 Replies

3. Shell Programming and Scripting

Getting the exit status of a remote command

Hi to everyone. How can I get the exit status from a remote command executed with rexec? :eek: machine A has RedHat Linux 9 and the remote machine B has SCO UNIX. Code: rexec -l user -p password host sh /u/files/scripts/seq_cal.sh 2006 08 I want the exit status returned by... (1 Reply)
Discussion started by: zoonalex
1 Replies

4. UNIX for Dummies Questions & Answers

Move Command and exit status problem

Hi All, I am using the following code to move files from one folder to another on the remote server: ssh username@server <<EOF cd source_dir find . -type f -name "*.txt" |xargs -n1000 -i{} mv {} dest_dir if then send mail indicating error otherwise echo "success" fi EOF ... (1 Reply)
Discussion started by: visingha
1 Replies

5. Shell Programming and Scripting

Move Command and exit status problem

Hi All, I am using the following code to move files from one folder to another on the remote server: ssh username@server <<EOF cd source_dir find . -type f -name "*.txt" |xargs -n1000 -i{} mv {} dest_dir if then send mail indicating error otherwise echo "success" fi EOF ... (10 Replies)
Discussion started by: visingha
10 Replies

6. Shell Programming and Scripting

Find exit status problem

Hi All Its strange or i am doing it wrong.When find run successful it return exit status 0.And same if it didn't run successfully it return zero. find /var/www/html -maxdepth 1 -type f -name *.dsadas echo $? 0 find /var/www/html -maxdepth 1 -type f -name *.php... (1 Reply)
Discussion started by: aliahsan81
1 Replies

7. HP-UX

Logins command exit status is 236 not 0

I have noticed that on version 11.23 I get exit status 236 from the following command: logins -oxl root ; echo $? > 236 However on 11.31 I get the expected code 0 logins -oxl root ; echo $? > 0 The output is correct for both versions and contains no error data. Can anyone explain... (2 Replies)
Discussion started by: parkea2
2 Replies

8. UNIX for Advanced & Expert Users

Equivalents of tee command to find exit status of command

Hi, Want to log the output of command & check the exit status to find whether it succeeded or failed. > ls abc ls: abc: No such file or directory > echo $? 1 > ls abc 2>&1 | tee log ls: abc: No such file or directory > echo $? 0 Tee commands changes my exit status to be always... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

9. Shell Programming and Scripting

Unable to find exit status of piped command

Lois_Answer_Code=`sipsak -vv -s sip:192.168.1.3|grep -A 1 "reply received after"|grep SIP|awk '{print $2}'`How to find the exit status of | (12 Replies)
Discussion started by: proactiveaditya
12 Replies

10. Shell Programming and Scripting

Exit Status of Command

Hi All, I am doing an export and import (datapump) of 4 schema. I know we can do an export of 4 schema in one command. But just want to know how to check the exit status if i do the export/import of 4 schema in different commands in background. Please suggest. Thanks, Mani (1 Reply)
Discussion started by: pvmanikandan
1 Replies
condor_rmdir(1) 					      General Commands Manual						   condor_rmdir(1)

Name
       condor_rmdir Windows - only no-fail deletion of directories

Synopsis
       condor_rmdir [/HELP | /?]

       condor_rmdir@filename

       condor_rmdir[/VERBOSE] [/DIAGNOSTIC] [/PATH:<path>] [/S] [/C] [/Q] [/NODEL] directory

Description
       condor_rmdircan delete a specified directory, and will not fail if the directory contains files that have ACLs that deny the SYSTEM process
       delete access, unlike the built-in Windows rmdircommand.

       The directory to be removed together with other command line arguments may be specified within a file named filename, prefixing this  argu-
       ment with an  @ character.

       The  condor_rmdir.exeexecutable is is intended to be used by Condor with the /S/Coptions, which cause it to recurse into subdirectories and
       continue on errors.

Options
       /HELP

	  Print usage information.

       /?

	  Print usage information.

       /VERBOSE

	  Print detailed output.

       /DIAGNOSTIC

	  Print out the internal flow of control information.

       /PATH:<path>

	  Remove the directory given by <path>.

       /S

	  Include subdirectories in those removed.

       /C

	  Continue even if access is denied.

       /Q

	  Print error output only.

       /NODEL

	  Do not remove directories. ACLs may still be changed.

Exit Status
       condor_rmdirwill exit with a status value of 0 (zero) upon success, and it will exit with the standard HRESULT error code upon failure.

Author
       Condor Team, University of Wisconsin-Madison

Copyright
       Copyright (C) 1990-2012 Condor Team, Computer Sciences Department, University of  Wisconsin-Madison,  Madison,  WI.  All  Rights  Reserved.
       Licensed under the Apache License, Version 2.0.

       See the Condor Version 7.8.2 Manualor http://www.condorproject.org/licensefor additional notices. condor-admin@cs.wisc.edu

								  September 2012						   condor_rmdir(1)
All times are GMT -4. The time now is 04:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy