Your sed command is missing the closing single quote.
I would also suggest using the "$( )" format for command substitution instead of backquotes, unless you need to remain compatible with an older shell that does not support that syntax. It handles nested command substitution commands
much cleaner:
Which is easier to understand, this one where you have to escape the nested backquotes:
Or this one, where you don't?
Last edited by gary_w; 05-11-2012 at 11:01 AM..
Reason: Added command substitution example
I have the results of a grep with -n store in a shell variable
ie
VAR=`grep -n -e 'PATTERN' file`
How ever I am missing the line breaks in the variable , How do I store the resualts of grep with many lines in to a variables. I want the varable should be the sawmway as we do the grep
grep... (3 Replies)
I have a variable A
echo $A
5060
I am exporting the value X,Y,Z and it id fetching right thing and When I run
C=`${X} -l ${Y} ${Z} "trap '' INT;. ~/.profile >/dev/null 2>/dev/null; netstat -na | grep \$A`"
here it is going to same directory and also running netstat -na | grep 5060
... (4 Replies)
Hello,
I have a question regarding the awk command. Here is the line I need to grep:
1 F= -.13250138E+03 E0= -.13249556E+03 d E =-.174650E-01 mag= 35.2157
Instead of displaying the number in red I would like to store it as a variable such as X. Is there a way to do this? Thanks for any... (3 Replies)
Hi,
I have a file contains attribute value pair like..
..name=erick rollno=583.0 pass=recon..
From the above line, i need to grep for only "rollno" and store "rollno=583.0" in a variable.
Pls suggest (6 Replies)
Hi all,
I have a script in which i need to run a command like "/opt/dell/srvadmin/sbin/omreport about" and output will be something like
Version : 6.3.0
Copyright : Copyright (C) xxx Inc. 1995-2010 All rights reserved.
Company : xxx Inc.
In this i need to save the version... (13 Replies)
Hi,
I am trying to do the following thing
var='date'
$var
Above command substitutes date for and in turn runs the date command and i am getting the todays date value.
I am trying to do the same thing as following, but facing some problems,
unique_host_pro="sed -e ' /#/d'... (3 Replies)
Guys, I was wondering what command can be used to parse the "LaxOrdID" field into a separate file? These messages are in thousands and I need to perform a comparision. (6 Replies)
In a directory i have a file *output* whose contents are changing for every simulation.
zgrep "trace file is" *output* | zgrep g
o/p: trace file is Int_01.1352176388z4f56ec33.0.trace.gz
I want to extract "Int_01.1352176388z4f56ec33.0.trace.gz" from the above result into a variable.
i... (2 Replies)
!#bin/bash
clear
var= grep @gmail.com email.txt | wc -l
echo $var
echo $var
exit 0
OUTPUT:
1000
_
_
Where _ represent space (no value or nothing) (4 Replies)
Discussion started by: Muhammad Rehan
4 Replies
LEARN ABOUT HPUX
zgrep
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)