Sponsored Content
Top Forums Shell Programming and Scripting New Unix user with shell script question using grep Post 302523374 by verdepollo on Wednesday 18th of May 2011 05:14:13 PM
Old 05-18-2011
You almost got it there. You can "and" the result with &&; its usage is pretty much the same as "||"

Code:
grep -iq 'error' monplus.mplog \
&& echo -e "There is an error in the monplus.mplog file\nPlease investigate" \
|| echo "There are no errors in the monplus.mplog file"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to hide user inputted text for interactive unix shell script?

Hi everybody, Do you know how to hide the text for interactive unix shell script? Just like the case for inputting password during logon. Patrick (1 Reply)
Discussion started by: patrickpang
1 Replies

2. Shell Programming and Scripting

Unix shell script (grep -A 6 -B 2 "ORA-" filename

BACKGROUND: I am using Solaris 10. Some of my boxes have gnu grep and I can use -A and -B flags on those. However, the solaris flavor of grep won't use the flags -A or -B. And some of my boxes won't be getting gnu grep. Should I try using perl, awk, or sed? Actual PROBLEM: I am... (7 Replies)
Discussion started by: el_guero
7 Replies

3. Shell Programming and Scripting

Unix Shell Script Help - Grep

Hi, I am new to UNIX Shell scripting, and will require some help. I am trying to search a directory with a number of files for a specific word, then if that word is found in any of the files, then the filename is appended to a log file or result file by ">" command. I have been trying to... (2 Replies)
Discussion started by: Sypherg
2 Replies

4. AIX

AIX 4.2 Korn shell and grep question

Ho do I find out the verion of the Kron shell on my client`s system ? There is no one to ask. They are not knowledged enough (hard to believe but yes). Also, on that AIX 4.2, I am trying to figure out how to do a grep using a search patter like below but does not seam to work. The '*' do... (11 Replies)
Discussion started by: Browser_ice
11 Replies

5. Shell Programming and Scripting

Unix Shell scripting -How to skip User Standard input section from another script

All, problem Description: For example: I have two shell scripts(executables). let name it as script1 and script2.I'm trying to execute script1 from script2. while executing script2, script1 is asking for manual input(input from keyboard). Now i need to know how I can skip this user input... (3 Replies)
Discussion started by: techie99
3 Replies

6. Solaris

grep in a shell question

Hi Experts, I am able to run the below command via command line without any issues: cat test.txt | grep -A 2 "Title" However, when I put this same command on test.sh and do a ./test.sh, I get the error "grep: illegal option -- A Usage: grep -hblcnsviw pattern file . . ." Would... (3 Replies)
Discussion started by: marcusbrutus
3 Replies

7. Shell Programming and Scripting

Unix Shell Script question

I have the following script ========= #!/bin/sh MUTEXPREFIX="/tmp/" READMUTEX=(test globallock) # If mutexes found - exit out for m in "${READMUTEX}"; do || (echo "$0 Mutex file found - Exiting\n" ; exit 1) done; echo "After for loop\n"; exit;============= What i want... (8 Replies)
Discussion started by: GosarJunk
8 Replies

8. Shell Programming and Scripting

UNIX question on grep

Dear Sir, I need to remove the word /klp/ in all the files present in the directories can you tell me how to remove the word globally. grep "/klp/" * -exec ls -l Once the above command is exectubed I could see lot of files displayed. (8 Replies)
Discussion started by: ramkumar15
8 Replies

9. Shell Programming and Scripting

UNIX shell script question.

I need to check whether the directory is exist or not. only three letter will be passed as argument. from that it should pick the entire directory. Instead of banking and manfucuture the input will be passed as man or ban. $1 -> ban $2-> monday #!/bin/sh DIR='/sales/$1*/monday' if ;... (3 Replies)
Discussion started by: arun888
3 Replies

10. Shell Programming and Scripting

Shell script to set user password to never expire in UNIX servers

Hi, I have a requirement where in i need to write a shell script to set users password to never expire. I know the command which is used to perform the same .. which is chage command. But, could not figure out how to do the same in shell script. Could you please help me with the shell... (3 Replies)
Discussion started by: suren424
3 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 09:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy