Sponsored Content
Top Forums UNIX for Advanced & Expert Users Advance conditional grep command Post 302554235 by itkamaraj on Sunday 11th of September 2011 12:48:29 AM
Old 09-11-2011
In that case, it works for you.
Code:
$ awk 'BEGIN{RS="EndOfRecord"} $0~/PLMNCode=455F00/ {print $0"EndOfRecord"}' contents.bk 
StartOfRecord
dateAndTimeStart = 20110904091315
PLMNCode=455F00
dateAndTimeEnd = 20110904091415
EndOfRecord

StartOfRecord
dateAndTimeStart = 20110905142111
[COLOR="rgb(255, 0, 255)"]PLMNCode=455F00[/COLOR]
dateAndTimeEnd = 20110905152111
EndOfRecord

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Looping and conditional branching on the command line

I am piping STDOUT from commands such as ifconfig and dmesg through grep, sed and awk to get the information I need. I need to now perform some looping and branching now and have been trying to figure out how to do this on the command line. You may ask "Why the command line? - Why not put it... (2 Replies)
Discussion started by: karlgo
2 Replies

2. UNIX for Advanced & Expert Users

Regarding Advance installation

Hi to all, I have one doubt in unix/linux installation. There are two systems in which one is Sparc system having no CD-Rom, No O/S and fresh Hard disk and another system is having windows O/S. Now, can i install unix or linux o/s in the Empty Sparc System by using other system which is... (1 Reply)
Discussion started by: sasidarvarma
1 Replies

3. Shell Programming and Scripting

Conditional mailing as command result

Hi ! I would like to be informed by mail when a ping conmand exceeds a certain avarage value. This is the output of the ping command rtt min/avg/max/mdev = 164.505/165.522/166.540/1.095 ms I need to get the second value (165.522) and if greater than 200, send a mail. This should... (2 Replies)
Discussion started by: gadile
2 Replies

4. Shell Programming and Scripting

Conditional checking for VMWARE command

Hello, I have to runt he following VMWARE script to take a snap shot of my machine: vmware-cmd -v /vmfs/volumes/44e9c20f-71ded630-3ac2-00137221e12a/orion/orion.vmx createsnapshot Weekly_Backup I need to check if successfully executes or not so I thought I would put it in a IF STATEMENT ... (2 Replies)
Discussion started by: mojoman
2 Replies

5. Programming

Advance FIND Command

Hi, I have to find jar file name and its path by passing it containing class file name, jar is a kind of zip. by using following command I am able to get jar file name by passing class file name. find -name "*.jar" -exec grep "CLASSNAME" {} \; find -name "*.jar" -exec grep... (3 Replies)
Discussion started by: niceboykunal123
3 Replies

6. Shell Programming and Scripting

if statement with grep as conditional

Please see the script segment below for i in $files do echo $i if ; then case "$1" in "IE0263"|"IE0264"|"IE0267"|"IE0268") short_filename=`ls -l $i | cut -c108-136 | sort` ;; "IE0272"|"IE0273") short_filename=`ls -l $i | cut... (4 Replies)
Discussion started by: jmahal
4 Replies

7. Shell Programming and Scripting

Conditional Multi-Line Grep Problem

Hi, I have a very large file I want to extract lines from. I'm hoping Grep can do the job, but I'm running into problems. I want to return all lines that match a pattern. However, if the following line of a matched line contains the word "Raw" I want to return that line as well. Is this... (3 Replies)
Discussion started by: redbluefish
3 Replies

8. Shell Programming and Scripting

Conditional grep command to search entire file

Let me give you a complete example what I am trying to achieve. 1. Below is the log file structure where I need 2,5 and 14th column of the logs after grepping through the linkId=1ddoic. Log file structure:- abc.com 20120829001415 127.0.0.1 app none11111 sas 0 0 N clk Mozilla/5.0... (3 Replies)
Discussion started by: kmajumder
3 Replies

9. Programming

Python Conditional Statements Based on Success of Last Command

In shell scripting, I can create a conditional statement based on the success or failure (exit status)of a command such as: pinger() { ping -c 2 $remote_host >/dev/null 2>&1 ping_stat=$? } pinger if ]; then echo "blahblahblah" exit 0 fi how is this done using Python using... (3 Replies)
Discussion started by: metallica1973
3 Replies

10. UNIX for Dummies Questions & Answers

Bashrc File - Conditional Command Execution?

Hello All, I was wondering if there is a way to execute a command in my ".bashrc" file based on how I logged into the PC? I was thinking maybe there is a way to check how the user (*myself) logged in, maybe somehow with the who command along with something else, but I'm not sure... I know I... (7 Replies)
Discussion started by: mrm5102
7 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 11:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy