09-07-2018
Hello, Boris.
If "quiet" (-q) isn't used then grep will print any text it finds, to standard output (you can, similarly, make it "quiet" using grep ... >/dev/null). Using -q does not affect the return code of the command. That's what's captured with ||. Using || is telling the shell to execute whatever follows, if grep fails (returns a non-zero return code). If you want to execute the "/bin/sh..." on a successful grep match, you should use && instead. Sometimes with these multi-line type of commands, it's simpler just to use an if statement.
This User Gave Thanks to Scott For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a list of id;
for example: file 1
dfghd
dfghe
dfgey
dfgeu
I have another data file that contain this ids as headers;
for ex. file2
>dfghd
gfdgfddl;klfkld;ld;lgl;dld'l'dv
>dfghe
gkwhjhsgdjdjdjhjddj
>dfgey
jdkjfhdjhfdkjhfdkhkdk
I wanted to compare file 1 and file 2... (1 Reply)
Discussion started by: Lucky Ali
1 Replies
2. Shell Programming and Scripting
This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord
but only one record is getting wrote in DB.... Please advise ASAP...:confused:
function InsertFtg
{
FTGSTR=""
echo "Saurabh is GREAT $#"
let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies
3. Shell Programming and Scripting
For some reason,
@logs is a list of log files
@filter is a list of expressions to grep out
foreach (@logs){
open READ, "<$_" or die $!;
@temp=<READ>;
close READ;
foreach (@filter){
print grep /$_/,@temp ;
}
}
returns a regex error in one of the files... (4 Replies)
Discussion started by: adelsin
4 Replies
4. UNIX Desktop Questions & Answers
Hi Guys,
I have a very limited knowledge on shell scripting.
When I execute dspmq, I get either
" Running" or "Running in Standby" as output
$dspmq
QM1 Running
QM2 Running as StandByI want my script to run only if the output of dspmq is "Running".
I executed the below... (6 Replies)
Discussion started by: vandi
6 Replies
5. Shell Programming and Scripting
Hello again,
Am having an issue now with getting a simple grep command to work within a function..
The function is as below...
function findRecord() {
output=grep "001" recordDatabase
echo $output
}
At the moment the "001"... (3 Replies)
Discussion started by: U_C_Dispatj
3 Replies
6. Shell Programming and Scripting
I'm putting together a script that will search my mail archives for emails that meet certain criteria and output the files to a text file.
I can manually cat that text file and pipe it into sendmail and it will work (i.e. cat /pathtofile/foo.txt | sendmail -t me@company.com)
My script sends... (7 Replies)
Discussion started by: binary-ninja
7 Replies
7. How to Post in the The UNIX and Linux Forums
I am using a grep command with two patterns in my KSH script. File has line breaks in it and both the patterns are in different lines. Here is the command - grep -l 'RITE AID.*ST.820' natriter820u.20140914
Pattern1 - RITE AID
Pattern2 - ST*820
I am not getting any results from this,... (3 Replies)
Discussion started by: Raghav Garg
3 Replies
8. UNIX for Dummies Questions & Answers
Hello
I am using a grep command with two patterns in my KSH script. File has line breaks in it and both the patterns are in different lines. Here is the command grep -l 'RITE AID.*ST.820' natriter820u.20140914
Pattern1 - RITE AID
Pattern2 - ST*820
I am not getting any results from... (24 Replies)
Discussion started by: Raghav Garg
24 Replies
9. Shell Programming and Scripting
The file starts like this:
Directory: <path to the script>
Script: <script fife name>
#!bin/ksh
##Comments
<actual script>
What is the use of the first two lines in the script? What if I save the file without them? What will be the effect? They are not comments. Im very new to this,... (4 Replies)
Discussion started by: remytom
4 Replies
10. Shell Programming and Scripting
Dear All.
I have a script, which process files one by one. In the script I have two functions.
one sftp files to different server
the other from existing file create file with different name.
My question is:
Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 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)