Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

unix and linux commands - unix shell scripting

return code of a unix command

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-02-2007   -   Original Discussion by ramky79
ramky79's Unix or Linux Image
ramky79 ramky79 is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 25 March 2015, 1:18 PM EDT
Posts: 107
Thanks: 2
Thanked 2 Times in 2 Posts
return code of a unix command

How to find out whether the command I executed is successful or unsuccessful(at commandlinet)

Eg:
say i execute the following command at command line
rm *
How do i find out whether my previous command is a success or failure.

Thankyou.

Best Regards,
Ram.
Sponsored Links
    #2  
Old Unix and Linux 08-02-2007   -   Original Discussion by ramky79
jim mcnamara's Unix or Linux Image
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 12 January 2018, 4:18 PM EST
Location: NM
Posts: 11,280
Thanks: 581
Thanked 1,125 Times in 1,036 Posts
Note: rm * can be very dangerous, be careful



Code:
<some command>
echo "$?"

will display 0 if "some command" was successful. It will show 1 (or another non-zero number) if the command failed. Usually commands also display error messages when something goes wrong.
Sponsored Links
Closed


Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Unix return code example khchong Shell Programming and Scripting 4 09-28-2011 03:33 AM
Managing awk return code over SSH command maverick72 Shell Programming and Scripting 11 09-23-2011 05:23 AM
Return code of command assigned to variable browndr Shell Programming and Scripting 2 08-05-2008 09:26 AM
to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's manas6 UNIX for Dummies Questions & Answers 0 06-05-2008 07:44 AM
Move command return with exit code of 2 handak9 UNIX for Advanced & Expert Users 1 08-26-2004 06:40 AM



All times are GMT -4. The time now is 03:49 PM.