Don was VERY accurate when quoting what the OP's variables are to be like.
Here is another example and there are so, so many more after experimentation that UNLESS the OP can guarantee that his variables will only be alpha-numeric without any other '=' inside any of his basic variables then this could well be a daunting task. Who is to say that this cannot occur:
Code:
Last login: Sat Dec 23 16:12:07 on ttys000
AMIGA:amiga~> echo 'localhost subscriptions='["production", "masters", "fileserver", "cldb", "nfs"]' handler="genie"
> host1.localhost.com a=apple
> host2.localhost.com b=ball c=[ x+y=z ]' > /tmp/test
AMIGA:amiga~>
AMIGA:amiga~> cat /tmp/test
localhost subscriptions=[production, masters, fileserver, cldb, nfs] handler="genie"
host1.localhost.com a=apple
host2.localhost.com b=ball c=[ x+y=z ]
AMIGA:amiga~>
AMIGA:amiga~> grep -Eo '[[:alpha:]]+=([[:alpha:]]+|"[^"]*"'"|'[^']+')" /tmp/test
handler="genie"
a=apple
b=ball
y=z
AMIGA:amiga~> # Now WHERE is 'c'?
AMIGA:amiga~> _
Note: c=[ x+y=z ] ...
Where is 'c'? 'y' has suddenly appeared AS a variable. Who is to say that what I have done will not occur?
Don has given what the OP appeared to want exactly, but, and a big but, I have pointed out several pitfalls, not in Don's code but as a backup to it.
Don needs a much better description of what the OP considers a 'variable' AND I totally agree with him!
IN a file I need to check for 3 patterns if all the 3 patterns are in the file. I need to send out an email. All this needs to be done in korn shell script. Please advise. (1 Reply)
Hi,
I have a log file which might have certain paragraphs.
Switch not possible Error code 1234
Process number 678
Log not available Error code 567
Process number 874
.....
......
......
Now I create an exception file like this.
cat text.exp
Error code 1234
Process number 874 (7 Replies)
In a directory, there are two different file extensions (*.txt and *.xyz) having similar names of numerical strings (*). The (*.txt) contains 5000 multiple files and the (*.xyz) also contains 5000 multiple files. Each of the files has around 4000 rows and 8 columns, with several unique string... (5 Replies)
I have a file name in $f. If $f has "-" at the beginning, or "=", or does not have extension ".ry" or ".xt" or ".dat" then cerr would not be empty.
Tried the following but having some problems.
set cerr = `echo $f | awk '/^-|=|!.ry|!.xt|!.dat/'` (4 Replies)
Hi Guys,
I have file like below, I want to print all lines between test1231233 to its 10 occurrence(till line 41)
test1231233
qwe
qwe
qweq123
test1231233
qwe
qwe
qweq23
test1231233
qwe
qwe
qweq123
test1231233
qwe
qwe
qweq123131 (3 Replies)
Hi,
I need to find records with a search string from a file. Search strings are provided in a file.
For eg. search_String.txt file is like below
chicago
mexico
newark
sanhose
and the file from where the records need to be fetched is given below
src_file:... (1 Reply)
Hi Experts
I need to match 2 patterns consecutively and display 25 lines after that.
1st one - Error
2nd one - End string ( comes along with the pattern one)
3rd one - error
Logic
grep "ERROR OCCURRED :" trace.log | awk -v "ES=:" -v "SS=java.lang.NullPointerException" '{
if($NF ~... (8 Replies)
Hi,
I have requirement to find the matching patterns of two files in Unix. One file is the log file and the other is the error list file. If any pattern in the log file matches the list of errors in the error list file, then I would need to find the counts of the match.
For example,
... (5 Replies)
Delete patterns matching
OS version: RHEL 7.3
Shell : Bash
I have a file like below (pattern.txt). I need to delete all lines starting with the following words (words separated by comma below) and ) character.
LOGGING, NOCOMPRESS, TABLESPACE , PCTFREE, INITRANS, MAXTRANS, STORAGE,... (3 Replies)
Discussion started by: John K
3 Replies
LEARN ABOUT X11R4
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)