Sponsored Content
Top Forums Shell Programming and Scripting A question about if statement Post 302579145 by balajesuri on Monday 5th of December 2011 12:43:17 AM
Old 12-05-2011
$? is the exit status of the last command executed. Check the below post:
https://www.unix.com/unix-dummies-que...it-status.html

You may try something like this:
Code:
#! /bin/bash

verify()
{
    # do something
    grep -q 'VERIFICATION SUCCESSFUL' result.txt
    verify_exit_status=$?
}

verify

if [ $verify_exit_status -eq 0 ]; then
    echo debug
fi

By the way, what did you mean by this:
Quote:
return $(grep -q 'VERIFICATION SUCCESSFUL' result.txt)
This User Gave Thanks to balajesuri For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Another question on awk - Begin statement

Hi, I've a question on awk. In English I want to: (a) open a file, (b) search through the file for records where length of field15 > 20 characters and (c) print out some fields in the record. I've written the following and it works OK. The trouble is this will ALWAYS write out the column... (5 Replies)
Discussion started by: eff_cee
5 Replies

2. Shell Programming and Scripting

IF statement question

Hi there We have boxes named server-sybase2, server-oracle1, etc etc Does any body know how I can construct an if statement to say, if the hostname of the box contains the string "sybase" then do X ie if then X fi any help would be greatly appreciated (6 Replies)
Discussion started by: hcclnoodles
6 Replies

3. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

4. Shell Programming and Scripting

compound Bash if then statement question

I am writing a Bash script that will either clone a database or setup a standby database. So Parameter 2 will be the operation type. If the value is not clone or standby I want to throw an error message. I suppose I can also do a case block. So far i have been unable to get the syntax working... (1 Reply)
Discussion started by: gandolf989
1 Replies

5. Shell Programming and Scripting

ksh "case" statement question

Hi I have the following case statement: case $larg in *_* ) a=${larg%_*}; b=${larg#*_}; ;; *^* ) a=${larg%^*}; b=${larg#*^}; ;; esac I cannot figure out what *_* and *^* stand for... Also what a=${larg%_*}; b=${larg#*_}; and a=${larg%^*}; b=${larg#*^}; ... (1 Reply)
Discussion started by: aoussenko
1 Replies

6. Shell Programming and Scripting

perl : semi complex if statement question

Hi there I am trying to write an if statement in perl that will return "SUCCESS" if either of these conditions are true a) if $changes is greater than 5 AND the $force flag is set to 1 OR b) if $changes is greater than 0 AND $changes is less than 6 #!/usr/bin/perl -w my $force =... (5 Replies)
Discussion started by: rethink
5 Replies

7. Shell Programming and Scripting

Quick question regarding if statement

Hi, I'm trying to write an if statement that will check the USER parm against some text but I'm not quite sure how to use the or switch in the statement.. Can anyone help me out?... If someone could also let me know when to use ( or if (( $USER != "user1" || "user2" || "user3" || "user4" ))... (6 Replies)
Discussion started by: Jazmania
6 Replies

8. Programming

question about how the if statement works

on C programming, on an if statement, if u have something like if A && B && C { } if A is false, will it still move on to B and check it? (1 Reply)
Discussion started by: omega666
1 Replies

9. UNIX for Dummies Questions & Answers

Question using 2 variables in a "for" statement

Good Morning, I typically run a batch of commands, from the command line, to process server operating statistics. That would look like this: (these are days of the month) In this instance I am processing a directory of file for July 6th 7th etc. Those files would have names... (9 Replies)
Discussion started by: scotm
9 Replies

10. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 04:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy