I have a script that will search for a keyword in all the log files. It work just fine.
[..]
This code will not work since it contains an error because curly braces are used in the assignment.
For array assignment you need normal parentheses.
However, since "/Sandbox/logs/*" is quoted this results in an array with a single array element "/Sandbox/logs/*".
It works because the array contents gets expanded in the loop, since the variables are used without quotes, but it will not work with files with spaces in the name.
The proper way to do this would be this:
Although if there are not too many files this would be more efficient (and thus faster):
---
Quote:
Originally Posted by RudiC
Not sure what you're after. If it's the names of the files containig ALL of the keywords, try
You will need to adapt the keyword count (3) of the last grep, and the field number (8) of the last cut.
[..]
This does not do that . It returns the files that have matches on three lines for ANY of the keywords.
---
Quote:
Originally Posted by AbelLuis
Hi, you may try this:
The first line is for the expansion of parameters; the second, eval, parses and execute the built command.
Regards.
You do not need eval here, nor the quotes..
You can just use:
Assuming variables A[1-3] contain the strings that we are looking for..
Last edited by Scrutinizer; 05-13-2017 at 03:59 AM..
These 2 Users Gave Thanks to Scrutinizer For This Post:
Rats! You're right; I didn't think of duplicates. Wouldn't
be better?
Not really...
Let us imagine that file1 contains:
and that file2 contains:
and that file3 contains:
In this example, files file2 and file3 both contain all three strings, but the output from:
is:
which shows that only file1 comes up with a count of three unique matching lines.
Until we get a clear description of the desired output and the log file format, I think we're wasting our time guessing at what might supply the output the OP really wants.
This User Gave Thanks to Don Cragun For This Post:
I have several problems with my program: I hope you can help me.
1) the If else statement isn't working . The IF Else syntax is:
If MEMSIZE OR sasfoundation (SASEXE) OR Real Time(second) >1.0 and Filename, output column name and value to csv or else nothing
Example progflag,cvs:... (13 Replies)
The Problem that I am having is when the code ran and populated the progflag.csv file, columns MEMSIZE, SECOND and SASEXE were blank. The next problems are the IF else statement isn't working and the email function isn't sending the progflag.csv attachment.
a. What I want the program to do is to... (2 Replies)
I have below text file only with one line:
vi test.txt
This is the first test from a1.loa1 a1v1, b2.lob2, "c3.loc3" c3b1, loc4 but not from mot3 and second test from a5.loa5
Below should be the output that i want:
a1.loa1
b2.lob2
c3.loc3
loc4
a5.loa5
alv1 and c3b1 should be... (3 Replies)
Hi,
I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command.
Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns.
Xargs -I {} grep... (3 Replies)
Hi,
I have a file containing list of strings like
i:
Pink
Yellow
Green
and I have file having list of file names in a directory
j :
a
b
c
d
Where j contains of a ,b,c,d are as follows
a:
Pink (3 Replies)
Hi
I am trying to determine number of lines having a specific keyword.
So for that I am using below query:
grep -i 'keyword1' filename|wc -l
This give me number of lines. Perfect for me.
However now the requirement is
I have multiple keywords together... and I have to find number of... (3 Replies)
Hi to all
Sorry for the confusion because I did not explain the task clearly.
There are many .hhr files in a folder
There are so many lines in these .hhr files but I want only the following 2 lines to be transferred to the output file.
The keyword No 1 and all the words in the next line
They... (5 Replies)
hey guys,
Hey all,
I'm doing a project currently and want to index words in a webpage.
So there would be a file with webpage content and a file with list of words, I want an output file with true and false that would show which word exists in the webpage.
example:
Webpage content... (2 Replies)
I want to search files (basically .cc files) in /xx folder and subfolders.
Those files (*.cc files) must contain #include "header.h" AND x() function.
I am writing it another way to make it clear,
I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)