I read Chris Maes answer on how to a grep for a particular word in any file/files contained in a directory, and it worked. But, what is the way of finding the names of the files and the total number of files containing that word ? Please correct me if I am wrong. Thanks in advance !! Answer You just
Tag: grep
4 lines invert grep search in a directory that contains many files
I have many log files in a directory. In those files, there are many lines. Some of these lines contain ERROR word. I am using grep ERROR abc.* to get error lines from all the abc1,abc2,abc3,etc files. Now, there are 4-5 ERROR lines that I want to avoid. So, I am using This works fine. But when I insert 1
Comparing two files at end of line in Linux
I would like to compare two files and get the output of matching string in one of the files at the end of the line: Let’s say I have two files:- file1: file2: I could do something like this: This gives me the following output: This is because abcdef in file2 matches both of those lines in file1. However, what
Get information in the Log file
I have a log file and below is sample log in that file. I changed only here column 3rd and 4th as SourceNo,Destination for reference. my requirement – I need to get separately, Source wise total count that sent to Destination begin with 44 code. i tried with grep and awk but it didn’t work. appreciate your help. logs in
search numbers with egrep and regular expression
Given a file file1 with this text: I want to use egrep to search all the numbers that start with 5 and end with 1. I have tried: Answer This regex will work Regex Breakdown
Select lines by condition and count with one line command
I need help with analyze nginx logs. Sample of log: Is it possible to select with count all uniq ip addresses which contain per_page parameter and this parameter equal or greater than 100? So, the output can be in any format: Is it possible to get with one command? Answer This is absolutely basic awk – read the book Effective
Recursively grep unique pattern in different files
Sorry title is not very clear. So let’s say I’m grepping recursively for urls like this: grep -ERo ‘(http|https)://[^/”]+’ /folder and in folder there are several files containing the same url. My goal is to output only once this url. I tried to pipe the grep to | uniq or sort -u but that doesn’t help example result: Answer If
Convert number from text file
I have a file: id name date 1 paul 23.07 2 john 43.54 3 marie 23.4 4 alan 32.54 5 patrick 32.1 I want to print names that start with “p” and have an odd numbered id My command: grep “^p” filename | cut -d ‘ ‘ -f 2 | …. result: paul patrick Answer Awk can do it all:
How to invert the l-flag of grep
First question here, so go easy (: I have a 385 files which are the result of simulations, named ###_result.dat. However, some of the results resulted in errors, which I can grep for using the -l flag since these files always contain the character “=”. So getting the error-files is no problem: When I want to list the files without
How do you use wget to download most up to date file on a site?
Hello I am trying to use wget to download the most update to day McAfee patch and I am having issues singling out the .tar file. This is what I have: However when I run the above command it gives me: When I need it to just be the most recent.tar file in between the <a> </a> which in this